[ITK-users] Resampler to itk::image
AR_univr
andrea_kid90 at yahoo.it
Fri Dec 1 04:49:24 EST 2017
Hi,
I'm having problems to convert Resampler Output to itk::Image .
Here a snippet of what i'm doing :
const unsigned int ImageDimension = 3;
typedef unsigned char PixelType;
typedef itk::Image< PixelType, ImageDimension > InputImageType;
typedef itk::ResampleImageFilter< InputImageType, InputImageType
> ResamplerType;
. . .
InputImageType::Pointer inputImage = . . .
ResamplerType::Pointer resampler = ResamplerType::New();
InterpolatorType::Pointer interpolator = InterpolatorType::New();
resampler->SetInterpolator(interpolator);
InputImageType::SpacingType spacing = inputImage->GetSpacing();
InputImageType::PointType origin = inputImage->GetOrigin();
InputImageType::DirectionType direction = inputImage->GetDirection();
InputImageType::RegionType region = inputImage->GetBufferedRegion();
InputImageType::SizeType size = region.GetSize();
resampler->SetOutputSpacing(spacing);
resampler->SetOutputDirection(direction);
resampler->SetOutputOrigin(origin);
resampler->SetSize(size);
resampler->SetTransform(tps);
resampler->SetOutputStartIndex(region.GetIndex());
resampler->SetInput(inputImage);
std::cout << "[resampler] Written Origin : " <<
resampler->GetOutputOrigin()[0] << ", " << resampler->GetOutputOrigin()[1]
<< ", " << resampler->GetOutputOrigin()[2] << std::endl;
std::cout << "[resampler] Written Spacing : " <<
resampler->GetOutputSpacing()[0] << ", " << resampler->GetOutputSpacing()[1]
<< ", " << resampler->GetOutputSpacing()[2] << std::endl; std::cout
<< "[resampler] size : " << resampler->GetSize() << std::endl;
std::cout << "[resampler] transform : " << resampler->GetTransform() <<
std::endl;
std::cout << "[resampler] num of outs : " <<
resampler->GetNumberOfOutputs() << std::endl;
std::cout << "[resampler] Written Direction: \n" <<
resampler->GetOutputDirection() << std::endl;
Up to here i have the values, and it seems it's working.
But when i do
InputImageType::Pointer output = resampler->GetOutput();
output is empty, and i dont know why... Am i missing something?
any help would be appreciated
Thanks !
Andrea
--
Sent from: http://itk-insight-users.2283740.n2.nabble.com/
More information about the Insight-users
mailing list