[Insight-users] All zero output with ResampleImageFilter (ITK 3.4)
Víctor Rodrigo Córdoba
vrcordoba at gmail.com
Thu Nov 27 13:12:32 EST 2008
Hi All.
I have the following function to register models (modReader) to the size of
an active contour (contActivo). Xsize, ysize and zsize are the number of
rows, columns and slices of active contour bounding box.
When I execute it, the output of the Resample filter is all zero. I don't
know what I'm doing wrong.
I need your help.
typedef signed short PixelType;
typedef itk::Image< PixelType, 3 > ImageType;
typedef double FPixelType;
typedef itk::Image< FPixelType, 3 > FImageType;
typedef itk::ImageSeriesReader< ImageType > ReaderType;
ImageType::Pointer adaptarModeloImg4D(ReaderType::Pointer modReader,int
xsize,int ysize,int zsize,FImageType::Pointer contActivo)
{
typedef itk::ResampleImageFilter<ImageType,ImageType> ResampleFilter;
ResampleFilter::Pointer filResample = ResampleFilter::New();
filResample->SetInput(modReader->GetOutput());
typedef itk::LinearInterpolateImageFunction<ImageType, double >
InterpolatorType;
InterpolatorType::Pointer interpolator = InterpolatorType::New();
filResample->SetInterpolator(interpolator);
filResample->SetDefaultPixelValue(0);
const FImageType::SpacingType& spacing = contActivo->GetSpacing();
const FImageType::PointType& origin = contActivo->GetOrigin();
FImageType::SizeType sizeCA =
contActivo->GetLargestPossibleRegion().GetSize();
ImageType::SizeType sizeMod =
modReader->GetOutput()->GetLargestPossibleRegion().GetSize();
filResample->SetOutputOrigin(origin);
filResample->SetOutputSpacing(spacing);
filResample->SetSize(sizeCA);
// Computing scale on rows, columns and slices
double scaleX = (double)xsize/(double)sizeMod[1];
double scaleY = (double)ysize/(double)sizeMod[0];
double scaleZ = (double)zsize/(double)sizeMod[2];
// Tanking the minimum scale
double scale = scaleX<scaleY ? scaleX:scaleY;
scale = scale<scaleZ ? scale:scaleZ;
typedef itk::Similarity3DTransform< double > TransformType;
TransformType::Pointer transform = TransformType::New();
transform->SetScale(scale);
// Computing the beginning of the active contour
int posY= floor(((double)sizeCA[0]-(double)sizeMod[0]*scale)/2);
int posX= floor(((double)sizeCA[1]-(double)sizeMod[1]*scale)/2);
int posZ= floor(((double)sizeCA[2]-(double)sizeMod[2]*scale)/2);
// Moving model to active contour beginning
TransformType::OutputVectorType translation;
translation[0] = posY-origin[0];
translation[1] = posX-origin[1];
translation[2] = posZ-origin[2];
// Updating resample filter
transform->SetTranslation(translation);
filResample->SetTransform(transform);
filResample->Update();
return filResample->GetOutput();
}
Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20081127/ae0d717d/attachment.htm>
More information about the Insight-users
mailing list