[Insight-users] 3D affinetransform

Antoine Leimgruber antoine.leimgruber at sokal.ch
Wed Apr 11 14:13:54 EDT 2007


Hi Luis,

thank you for the reply. I forgot to look for tag (0020,0032) in the header because my code was previously using jpg images with a zero origin instead of dicom images.
 
Antoine

>Hi Antoine:
>
>
>This:
>
>      "...and did not know what to put in origin,
>            so I did set it to 0.0 0.0 0.0"
>
>
>explains everything.
>
>You cannot simply choose an arbitrary origin for the
>resampling grid. The coordinates of that origin are
>relevant for the resampling process.
>
>The resampling operation is done in Physical Space
>coordinates.
>
>The original image locations is specified by its
>origin. From that location you are translating it
>to a new origin:
>
>        inputOrigin + translation
>
>Now, imagine the grid of the image that you want
>to get as output of the resampling process. If
>you arbitrarily decide to place your output grid
>in an origin of 0.0,0.0,0.0 location, then this
>grid may not overlap at all with the grid of the
>translated input image.
>
>
>Please read the ITK Software Guide.
>
>
>     http://www.itk.org/ItkSoftwareGuide.pdf
>
>The details of the image resampling process are
>explained in Section 6.9.4 "Resample Image Filter"
>in pdf-pages: 254-284.
>
>Pay particular attention to figures
>
>   6.43 : pdf-page 260
>   6.44 : pdf-page 262
>   6.45 : pdf-page 262
>   6.46 : pdf-page 263
>
>
>The key to this process is to map all the images
>to a common coordinate system in physical space.
>
>
>
>    Regards,
>
>
>       Luis
>
>
>
>---------------------------
>Antoine Leimgruber wrote:
>> Hello,
>> 
>> I am using DicomSeriesReadImageWrite2.cxx to read a dicom series.
>> Everything goes well with DicomSeriesReadImageWrite2.cxx and my dicom files.
>> I am trying to modify ResampleImageFilter3.cxx from a 2D (which works well) to a 3D affinetransform.
>> If I insert my 3D version of a translation in DicomSeriesReadImageWrite2.cxx before the writer->Update, then all the pixels of the output image have the value set in SetDefaultPixelValue, even if I set the translation to 0.0 0.0 0.0
>> I have checked that spacing and size were right and did not know what to put in origin, so I did set it to 0.0 0.0 0.0
>> 
>> Here is the code of the translation that I inserted in DicomSeriesReadImageWrite2.cxx 
>> 
>> Thank you for your help
>> 
>> Antoine
>> 
>> 	typedef itk::ResampleImageFilter<ImageType,OutputImageType> FilterType;
>> 	FilterType::Pointer filter = FilterType::New();
>> 
>> 	typedef itk::AffineTransform< double, Dimension >  TransformType;
>> 	TransformType::Pointer transform = TransformType::New();
>> 
>> 	typedef itk::NearestNeighborInterpolateImageFunction< ImageType, double >  InterpolatorType;
>> 	InterpolatorType::Pointer interpolator = InterpolatorType::New();
>> 	filter->SetInterpolator( interpolator );
>> 	
>> 	filter->SetDefaultPixelValue( 100 );
>> 	
>> 	double spacing[ Dimension ];
>> 	spacing[0] = 0.3125;//0.6;//0.4283; // pixel spacing in millimeters along X
>> 	spacing[1] = 0.3125;//0.6;//0.5350; // pixel spacing in millimeters along Y
>> 	spacing[2] = 1.0;//0.6;//0.5350; // pixel spacing in millimeters along Z
>> 	filter->SetOutputSpacing( spacing );
>> 
>> 	double origin[ Dimension ];
>> 	origin[0] = 0.0;  // X space coordinate of origin
>> 	origin[1] = 0.0;  // Y space coordinate of origin
>> 	origin[2] = 0.0;  // Z space coordinate of origin
>> 	filter->SetOutputOrigin( origin );
>> 
>> 	ImageType::SizeType   size;
>> 	size[0] = 128;  // number of pixels along X
>> 	size[1] = 128;  // number of pixels along Y
>> 	size[2] = 20;   // number of pixels along Z
>> 	filter->SetSize( size );
>> 
>> 	filter->SetInput( reader->GetOutput() );
>> 	writer->SetInput( filter->GetOutput() );
>> 	
>> 	TransformType::OutputVectorType translation0;
>> 	std::cout << "Please enter X translation translation in millimeters: ";
>> 	std::cin >>translation0[0];  // X translation in millimeters
>> 	std::cout << "Please enter Y translation translation in millimeters: ";
>> 	std::cin >> translation0[1];  // Y translation in millimeters
>> 	std::cout << "Please enter Z translation translation in millimeters: ";
>> 	std::cin >> translation0[2];  // Z translation in millimeters
>> 	transform->Translate( translation0, true);
>> 	
>> 	filter->SetTransform( transform );	
>> 
>> _______________________________________________
>> 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