[ITK] [ITK-dev] problems itk resample filter
Pfaehler, EAG (ngmb)
e.a.g.pfaehler at umcg.nl
Fri Sep 8 08:32:57 EDT 2017
Dear all,
I would need some help to resample so that it has isotropic voxels in the end.
For this, I wanted to use the Nearest Neighbor Interpolator and the ResampleFilterType.
My code is running, but the output of the filter has always the dimensions [0 0 0], so is not existent.
What am I doing wrong? (see code below)
Thanks in advance!
Elli
typedef itk::NearestNeighborInterpolateImageFunction<ImageType, T> NearestNeighborInterpolatorType;
typedef itk::ResampleImageFilter<ImageType, ImageType> ResampleFilterType;
typedef itk::AffineTransform <double, 3> TransformType;
//use nearest neighbor interpolation
typename NearestNeighborInterpolatorType::Pointer nearestNeighborInterpolator = NearestNeighborInterpolatorType::New();
typename ImageType::DirectionType direction;
typename TransformType::Pointer transform = TransformType::New();
//transform->SetIdentity();
typedef itk::NearestNeighborInterpolateImageFunction<ImageType, double> InterpolatorType;
//typedef itk::LinearInterpolateImageFunction<ImageType, double > InterpolatorType;
typename InterpolatorType::Pointer interpolator = InterpolatorType::New();
typename ResampleFilterType::Pointer resizeFilter2 = ResampleFilterType::New();
resizeFilter2->SetTransform(transform);
resizeFilter2->SetInterpolator( interpolator );
resizeFilter2->SetDefaultPixelValue(0);
//resizeFilter2->SetInterpolator();
const typename ImageType::SpacingType& inputSpacing = image->GetSpacing();
//sampling
double outputSpacing[3];
// Fetch original image size
const typename ImageType::RegionType& inputRegion = image->GetLargestPossibleRegion();
const typename ImageType::SizeType& inputSize = inputRegion.GetSize();
unsigned int oldWidth = inputSize[0];
unsigned int oldHeight = inputSize[1];
unsigned int oldDepth = inputSize[2];
unsigned int newWidth;
unsigned int newHeight;
unsigned int newDepth;
//get the new height etc of image
double minimum = inputSpacing[0];
if (inputSpacing[1]<minimum){
minimum = inputSpacing[1];
}
if (inputSpacing[2] < minimum){
minimum = inputSpacing[2];
}
outputSpacing[0] = minimum;
outputSpacing[1] = minimum;
outputSpacing[2] = minimum;
newWidth = (double) oldWidth * inputSpacing[0]/minimum;
ewHeight = (double) oldHeight * inputSpacing[1]/minimum;
newDepth = (double) oldDepth * inputSpacing[2]/minimum;
// Set the output spacing as specified on the command line
resizeFilter2->SetOutputSpacing(outputSpacing);
// Set the computed size
itk::Size<3> outputSize = { {newWidth, newHeight, newDepth} };
resizeFilter2->SetSize(outputSize);
// Specify the input for the resamplers
resizeFilter2->SetInput(image);
ImageType::Pointer imageNew = resizeFilter2->GetOutput();
const typename ImageType::RegionType& outputRegion = imageNew->GetLargestPossibleRegion();
const typename ImageType::SizeType& outputSize2 = outputRegion.GetSize();
________________________________
De inhoud van dit bericht is vertrouwelijk en alleen bestemd voor de geadresseerde(n). Anderen dan de geadresseerde(n) mogen geen gebruik maken van dit bericht, het niet openbaar maken of op enige wijze verspreiden of vermenigvuldigen. Het UMCG kan niet aansprakelijk gesteld worden voor een incomplete aankomst of vertraging van dit verzonden bericht.
The contents of this message are confidential and only intended for the eyes of the addressee(s). Others than the addressee(s) are not allowed to use this message, to make it public or to distribute or multiply this message in any way. The UMCG cannot be held responsible for incomplete reception or delay of this transferred message.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20170908/8b533a2a/attachment-0001.html>
-------------- next part --------------
_______________________________________________
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://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-developers
More information about the Community
mailing list