[Insight-users] Image Resampling Problem

Luis Ibanez luis.ibanez at kitware.com
Tue Jan 27 11:59:29 EST 2009


Hi Huanxiang

How do you arrive to the conclusion that the output
image values are zero ?

Did you load the image into a viewer an saw a black image ?
If so, what viewer was it ?

Have you actually measured the values in the output image ?

Your image is of type unsigned short, and it is a common mistake
to use viewers that do not rescale the intensity range....


    Please let us know


        Luis


---------------------
Huanxiang Lu wrote:
> 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 <mailto:huanxiang.lu at artorg.unibe.ch>
> 
> www.artorg.unibe.ch/ <http://www.artorg.unibe.ch/>
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users


More information about the Insight-users mailing list