[Insight-users] applying a transform to an otherset of images

ludovic Ferrer ferrer.ludovic at neuf.fr
Thu Apr 10 15:25:21 EDT 2008


Hi all,
I modified an  imageregistration example to perform a registration  
between 2 CT scans  with Mutual information.
I am currently trying to apply the caculated transformation  
(itk::VersorRigid3DTransform) to an other set of image (SPECT images)  
rigth after the registration process ... without succeed I must  
confess :-)

Here is the problem I am facing.  I would like to have your opinion on  
that piece of code ...

After registration I save correctly the registred CT volume.  Then, I  
am defining my NM volume :

> 	typedef itk::Image< unsigned short, Dimension >  FixedMNImageType;
> 	typedef itk::ImageFileReader< FixedMNImageType  >  
> FixedImageMNReaderType;
> 	
> 	FixedImageMNReaderType::Pointer  fixedImageMNReader  =  
> FixedImageMNReaderType::New();
> 	fixedImageMNReader->SetFileName(argv[4]); // my NM volume
> 	fixedImageMNReader->Update();

I am casting my NM images to the type of my CT volume in order to  
perform the resampling process.
> 	typedef itk::CastImageFilter<
>                         FixedMNImageType,
>                          MovingImageType> CastFilterMNFloatType;
> 	CastFilterMNFloatType::Pointer floatCastMN =  
> CastFilterMNFloatType::New();
> 	
> 	floatCastMN->SetInput(fixedImageMNReader->GetOutput());
> 	typedef itk::ResampleImageFilter<
>                             MovingImageType,
>                             FixedImageType > ResampleMNFilterType;
> 	ResampleMNFilterType::Pointer resamplerMN =  
> ResampleMNFilterType::New();
> 	resamplerMN->SetInput( floatCastMN->GetOutput() );
Then, I am applying the transformation to my NM volume.	
> 	resamplerMN->SetTransform(finalTransform);
> 	     resamplerMN->SetSize(    fixedImage- 
> >GetLargestPossibleRegion().GetSize() );
>    	resamplerMN->SetOutputOrigin(  fixedImage->GetOrigin() );
> 	resamplerMN->SetOutputSpacing( fixedImage->GetSpacing() );
I am using fixedImage as input of resampling because I'd like to put  
my final image as the same size that my CT scans
> 	resamplerMN->SetInterpolator(interpolator);
>         resamplerMN->SetDefaultPixelValue( 0 );
> 	resamplerMN->Update();
Then, I am creating an output file and downcasting it to unsigned  
short and I am creating a writer :
>     typedef  unsigned short  OutputMNPixelType;	
>     typedef itk::Image< OutputMNPixelType, Dimension >  
> OutputImageMNType;	
>     typedef itk::CastImageFilter<
>                         MovingImageType,
>                         OutputImageMNType> CastFilterMNType;
>     typedef itk::ImageFileWriter< OutputImageMNType >  WriterMNType;
>     WriterMNType::Pointer      writerMN =  WriterMNType::New();
>     CastFilterMNType::Pointer  casterMN =  CastFilterMNType::New();
>     writerMN->SetFileName("MN-reg.vtk");
Here I am downcasting my resampled volume to unsigned short and  
writing it to a file.
>     casterMN->SetInput(resamplerMN->GetOutput());
>     writerMN->SetInput(casterMN->GetOutput());
>     writerMN->Update();	
When I am looking at my output file, I have a volume which size is  
equal to CT size (256^2) ... so far so good ... that volume seems to  
be translated and rotated according to my transform but pixels are  
filled with 0 or 65536.

I am a bit puzzled a that time... If anybody have a clue, I greetly  
appreciate ...

Cheers

LF


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20080410/23c02957/attachment-0001.htm>


More information about the Insight-users mailing list