[Insight-users] Image Resampling Problem
Huanxiang Lu
huanxiang.lu at artorg.unibe.ch
Tue Jan 27 10:00:18 EST 2009
Hello, everyone
I am trying to use itkResampleImageFilter to make some transformation of the
image. But it seems that all the intensity value of the output is zero. Does
anybody know what's going on?
Thanks!
typedef itk::Image<unsigned short, 3> ImageType;
typedef itk::ImageFileReader<ImageType> ReaderType;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName( argv[1]);
typedef itk::ResampleImageFilter<ImageType, ImageType> ResampleType;
ResampleType::Pointer resampler = ResampleType::New();
reader->Update();
ImageType::Pointer inputImage = reader->GetOutput();
ImageType::SizeType size =
inputImage->GetLargestPossibleRegion().GetSize();
resampler->SetSize(size);
typedef itk::AffineTransform<double, 3> TransformType;
TransformType::Pointer transform = TransformType::New();
resampler->SetTransform(transform);
typedef itk::LinearInterpolateImageFunction<ImageType>
InterpolationType;
InterpolationType::Pointer interpolator = InterpolationType::New();
resampler->SetInterpolator(interpolator);
ImageType::SpacingType spacing = reader->GetOutput()->GetSpacing();
resampler->SetOutputSpacing(spacing);
double origin[2];
origin[0] = 0;
origin[1] = 0;
origin[2] = 0;
resampler->SetOutputOrigin(origin);
TransformType::OutputVectorType translation;
translation[0] = 10;
translation[1] = 0;
translation[2] = 0;
transform->Translate(translation);
resampler->SetDefaultPixelValue(0);
resampler->SetInput(reader->GetOutput());
resampler->Update();
typedef itk::ImageFileWriter<ImageType> WriterType;
WriterType::Pointer writer = WriterType::New();
writer->SetInput(resampler->GetOutput());
writer->SetFileName( argv[2] );
writer->Update();
_____________________________________________
Huanxiang Lu
Ph.D. Student, Medical Image Analysis
University of Bern
ARTORG Center for Biomedical Engineering Research
Stauffacherstrasse 78
CH-3014 Bern
Tel +41 31 631 59 49
Fax +41 31 631 59 60
huanxiang.lu at artorg.unibe.ch
<http://www.artorg.unibe.ch/> www.artorg.unibe.ch/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20090127/5cc878f9/attachment.htm>
More information about the Insight-users
mailing list