Discussion:
[ITK-users] Error encountered when padding: boundary condition is ITK_NULLPTR
avazuila
2017-08-29 10:56:01 UTC
Permalink
Hi all,

I just performed the segmentation of a vessel from a CT scan and I would
like to use it to mask the abovementioned vessel on the image. In order to
do so I would like to pad the segmentation image which is smaller than the
image from which it has been extracted.

I get the following error: "PadImageFilter: Boundary condition is
ITK_NULLPTR so no request region can be generated."

My code is the following:

double* voi_bounds = l_import_preprocess.getBounds();
double* seg_bounds = l_import_seg.getBounds();

double x_min = abs(voi_bounds[0] - seg_bounds[0]);
double x_max = abs(voi_bounds[1] - seg_bounds[1]);
double y_min = abs(voi_bounds[2] - seg_bounds[2]);
double y_max = abs(voi_bounds[3] - seg_bounds[3]);
double z_min = abs(voi_bounds[4] - seg_bounds[4]);
double z_max = abs(voi_bounds[5] - seg_bounds[5]);

const int Dimension = 3;
typedef uchar PixelType;
typedef itk::Image< PixelType, Dimension > ImageType;

ImageType::SizeType upper;
ImageType::SizeType lower;

lower[0] = x_min;
lower[1] = y_min;
lower[2] = z_min;

upper[0] = x_max;
upper[1] = y_max;
upper[2] = z_max;

typedef itk::PadImageFilter< ImageType, ImageType > PadFilterType;
PadFilterType::Pointer l_pad = PadFilterType::New();
l_pad->SetInput(l_import_seg.getOutput());
l_pad->SetPadUpperBound(upper);
l_pad->SetPadLowerBound(lower);

typedef itk::ImageFileWriter< ImageType > WriterFilterType;
WriterFilterType::Pointer l_writer = WriterFilterType::New();
l_writer->SetInput(l_pad->GetOutput());
l_writer->SetFileName(logDir.toStdString() + "voi.mhd");
try{
l_writer->Update();
}
catch (itk::ExceptionObject& err) {
M_Error(String(err.what()));
}

I also tried to crop the original image to make it fit the segmentation
dimensions but it always is a few pixels smaller than the segmentation image
and I have no idea why. Moreover, this gap is never the same and seems to be
proportional to the segmentation image size.

Why can't I perform the padding of my segmentation image?
Plus, does anybody know why I can't crop the original image without having a
few pixels less than needed?

Thanks in advance,

Marie



--
View this message in context: http://itk-users.7.n7.nabble.com/Error-encountered-when-padding-boundary-condition-is-ITK-NULLPTR-tp38654.html
Sent from the ITK - Users mailing list archive at Nabble.com.
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users
Matt McCormick
2017-08-29 12:24:49 UTC
Permalink
Hi Marie,

Is getBounds() returning physical coordinates or index coordinates?
PadImageFilter uses index coordinates.

Here is an example:

https://itk.org/ITKExamples/src/Filtering/ImageGrid/PadAnImageWithAConstant/Documentation.html

Hope this helps,
Matt
Post by avazuila
Hi all,
I just performed the segmentation of a vessel from a CT scan and I would
like to use it to mask the abovementioned vessel on the image. In order to
do so I would like to pad the segmentation image which is smaller than the
image from which it has been extracted.
I get the following error: "PadImageFilter: Boundary condition is
ITK_NULLPTR so no request region can be generated."
double* voi_bounds = l_import_preprocess.getBounds();
double* seg_bounds = l_import_seg.getBounds();
double x_min = abs(voi_bounds[0] - seg_bounds[0]);
double x_max = abs(voi_bounds[1] - seg_bounds[1]);
double y_min = abs(voi_bounds[2] - seg_bounds[2]);
double y_max = abs(voi_bounds[3] - seg_bounds[3]);
double z_min = abs(voi_bounds[4] - seg_bounds[4]);
double z_max = abs(voi_bounds[5] - seg_bounds[5]);
const int Dimension = 3;
typedef uchar PixelType;
typedef itk::Image< PixelType, Dimension > ImageType;
ImageType::SizeType upper;
ImageType::SizeType lower;
lower[0] = x_min;
lower[1] = y_min;
lower[2] = z_min;
upper[0] = x_max;
upper[1] = y_max;
upper[2] = z_max;
typedef itk::PadImageFilter< ImageType, ImageType > PadFilterType;
PadFilterType::Pointer l_pad = PadFilterType::New();
l_pad->SetInput(l_import_seg.getOutput());
l_pad->SetPadUpperBound(upper);
l_pad->SetPadLowerBound(lower);
typedef itk::ImageFileWriter< ImageType > WriterFilterType;
WriterFilterType::Pointer l_writer = WriterFilterType::New();
l_writer->SetInput(l_pad->GetOutput());
l_writer->SetFileName(logDir.toStdString() + "voi.mhd");
try{
l_writer->Update();
}
catch (itk::ExceptionObject& err) {
M_Error(String(err.what()));
}
I also tried to crop the original image to make it fit the segmentation
dimensions but it always is a few pixels smaller than the segmentation image
and I have no idea why. Moreover, this gap is never the same and seems to be
proportional to the segmentation image size.
Why can't I perform the padding of my segmentation image?
Plus, does anybody know why I can't crop the original image without having a
few pixels less than needed?
Thanks in advance,
Marie
--
View this message in context: http://itk-users.7.n7.nabble.com/Error-encountered-when-padding-boundary-condition-is-ITK-NULLPTR-tp38654.html
Sent from the ITK - Users mailing list archive at Nabble.com.
_____________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
http://www.kitware.com/products/protraining.php
http://www.itk.org/Wiki/ITK_FAQ
http://public.kitware.com/mailman/listinfo/insight-users
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users
avazuila
2017-08-29 12:41:03 UTC
Permalink
Hi Matt,

getBounds() returns physical coordinates. Do you know how I could get the
index coordinates? I am having a hard time managing to understand what
indexes are for and I can't see a getIndex() method in my code (I'm not the
author of these methods).

Thanks and regards,

Marie



--
View this message in context: http://itk-users.7.n7.nabble.com/Error-encountered-when-padding-boundary-condition-is-ITK-NULLPTR-tp38654p38656.html
Sent from the ITK - Users mailing list archive at Nabble.com.
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users
Matt McCormick
2017-08-29 14:14:33 UTC
Permalink
Hi Marie,

The relationship between pixel / index coordinates and physical space
is described in the ITK Software Guide:

https://itk.org/ITKSoftwareGuide/html/Book1/ITKSoftwareGuide-Book1ch4.html#x38-470004.1

There are methods on itk::Image to go between the two,
TransformIndexToPhysicalPoint and TransformPhysicalPointToIndex,

https://itk.org/Doxygen/html/classitk_1_1ImageBase.html#ab003313ba1a078d89a832dc0a35d2efa
https://itk.org/Doxygen/html/classitk_1_1ImageBase.html#af4a7c9c3787e9fdafbaaade2e02efa25

Hope this helps,
Matt
Post by avazuila
Hi Matt,
getBounds() returns physical coordinates. Do you know how I could get the
index coordinates? I am having a hard time managing to understand what
indexes are for and I can't see a getIndex() method in my code (I'm not the
author of these methods).
Thanks and regards,
Marie
--
View this message in context: http://itk-users.7.n7.nabble.com/Error-encountered-when-padding-boundary-condition-is-ITK-NULLPTR-tp38654p38656.html
Sent from the ITK - Users mailing list archive at Nabble.com.
_____________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
http://www.kitware.com/products/protraining.php
http://www.itk.org/Wiki/ITK_FAQ
http://public.kitware.com/mailman/listinfo/insight-users
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users

Loading...