[Insight-users] resampleFilter

Yankam Njiwa Josiane Adrienne njiwa at biomed.ee.ethz.ch
Thu Sep 4 12:21:41 EDT 2008


 
 
Dear all,
 
 
With the source code below i would like to apply the transform computed with IterativeClosestPoint to an image. When i write the image i have an empty file. I tried to write the same image without using the resampleFilter and and teh casteFilter and i can see the image. Please could somebody know where the problem is?
Thanks a lot with regards,
 
Josiane.
 
 
 
 

typedef unsigned char PixelType;

typedef itk::Image< PixelType, Dimension > ImageType;

typedef itk::ImageFileReader< ImageType > ImageReaderType;

ImageReaderType::Pointer ImageReader = ImageReaderType::New();

ImageReader->SetFileName( argv[3] );

 

typedef itk::ResampleImageFilter< 

ImageType, 

ImageType > ResampleFilterType;

ResampleFilterType::Pointer resampler = ResampleFilterType::New();

resampler->SetInput( ImageReader->GetOutput() );

resampler->SetTransform( registration->GetTransform() );

ImageType::Pointer Image = ImageReader->GetOutput();

resampler->SetSize( Image->GetLargestPossibleRegion().GetSize() );

resampler->SetOutputOrigin( Image->GetOrigin() );

resampler->SetOutputSpacing( Image->GetSpacing() );

resampler->SetOutputDirection( Image->GetDirection() );

resampler->SetDefaultPixelValue( 100 );

typedef itk::CastImageFilter< 

ImageType,

ImageType > CastFilterType;

typedef itk::ImageFileWriter< ImageType > WriterType;

WriterType::Pointer writer = WriterType::New();

CastFilterType::Pointer caster = CastFilterType::New();

caster->SetInput( resampler->GetOutput());

writer->SetInput( caster->GetOutput() );

writer->SetFileName( argv[4] );

try

{

writer->Update();

}

catch( itk::ExceptionObject & excp )

{

std::cerr << excp << std::endl;

}



More information about the Insight-users mailing list