[Insight-users] applying previously saved transform to images

Fritzsche Klaus k.fritzsche at dkfz-heidelberg.de
Wed Dec 3 07:41:08 EST 2008


Hi Andre,

you could also give a try to the Medical Imaging Interaction Toolkit
(MITK, http://www.mitk.org/), which is also an open source project based
on ITK/VTK. MITK is able to visualize and process images with arbitrary
geometries.

>Please give it a try to Slicer (www.slicer.org), this
>is probably the only application out there that will
>properly display two images of different spacing.

Best Regards,
Klaus


Klaus Fritzsche
Dipl.-Inform., M.Sc.
DKFZ
German Cancer Research Center (Deutsches Krebsforschungszentrum) 
Member of the Helmholtz Association
Division of Medical and Biological Informatics
Im Neuenheimer Feld 280
D-69120 Heidelberg
Phone: 49-(0)6221-42-3545
Fax: 49-(0)6221-42-2354
E-Mail: k.fritzsche at dkfz.de
Web: www.dkfz.de

Confidentiality Note: This message is intended only for the use of the
named recipient(s) and may obtain confidential and/or privileged
information. If you are not the intended recipient, please contact the
sender and delete the message. Any unauthorized use of the information
contained in this message is prohibited.






-----------------------------
a.bongers at mediri.com wrote:
> Hi, 
> 
> I'm having a problem with registration and transformation of an image
with different spacings. 
> What I would like to do is the following: 
> 
> Using the affine itk registration I have registered a 3D moving image
with spacing (4,4,4) to a fixed image with spacing (1,1,4) and have
saved the transformation to a file. This works well so far. The
registerd images seem to fit well. 
> 
> In later stage I would like to apply the saved transform to the moving
image but KEEPING THE SPACING OF THE MOVING IMAGE. (In effect I would
like to apply a transform determined previously to another image, i.e.
e.g. a mask image which I cannot register directly because it is lacking
sufficient structures) 
> --> 
> So I simply tried to use the resample image filter but with the
spacing from the moving image (4,4,4). 
> When I do this, the resulting image after the application of the
transform does not fit the fixed image but seems to be shifted by some
amount. 
> 
> Since I do not really know how this comes about I hope anybody can
help me... 
> Does the Transform depend on image spacing somehow ??? Am I thinking
wrongly ??? Is this a bug ??? How can I achieve a transform of the image
without being dependent on the fixed image ? 
> 
> 
> To illustrate what I am doing : Here is the code of the resampling
function I wrote. 
> The Problem is highlited in the source comments: 
> 
> 
> my func is templated over the image type and trafo type and takes the
trafo I previously read in from the itk transform file saved in the
registration stage. 
> 
> 
> template <class ImageType, class TrafoType> 
> //typename ImageType::Pointer ResampleImage(typename
ImageType::Pointer sourceImage, typename TrafoType::Pointer transform) 
> typename ImageType::Pointer ResampleImage(typename ImageType::Pointer
sourceImage, typename ImageType::Pointer targetImage, 
> typename TrafoType::Pointer transform) 
> { 
> 
> typedef itk::LinearInterpolateImageFunction<ImageType,double>
InterpolatorType; 
> InterpolatorType::Pointer interp = InterpolatorType::New(); 
> interp->SetInputImage(sourceImage); 
> 
> typedef itk::ResampleImageFilter<ImageType,ImageType>
ResampleImageFilter; 
> ResampleImageFilter::Pointer resample = ResampleImageFilter::New(); 
> resample->SetInput(sourceImage); 
> 
> resample->SetTransform(transform); 
> resample->SetInterpolator(interp); 
> 
> ImageType::IndexType index = {{0,0,0}}; 
> resample->SetOutputStartIndex(index); 
> 
> // here I get a problem when I try to use the source images spacing 
> // if I use the target's (i.e. fixed) image spacing everything works
fine: 
> ImageType::SizeType size =
targetImage->GetLargestPossibleRegion().GetSize(); 
> resample->SetSize(size); 
> resample->SetOutputSpacing(targetImage->GetSpacing()); 
> cout << targetImage->GetSpacing() << "spacing from target image
!!!!!!!!!!!!!"; 
> // this works ok 
> 
> 
> // but if I use the source's (moving) image spacing it does not work
--> the resuling transforemd image is then shifted 
> //ImageType::SizeType size =
sourceImage->GetLargestPossibleRegion().GetSize(); 
> //resample->SetSize(size); 
> //resample->SetOutputSpacing(sourceImage->GetSpacing()); 
> //cout << sourceImage->GetSpacing() << "spacing from source image
!!!!!!!!!!!!!"; 
> // this works ok 
> 
> resample->SetOutputOrigin(sourceImage->GetOrigin()); 
> 
> resample->Update(); 
> ImageType::Pointer outImage = resample->GetOutput(); 
> outImage->SetDirection(sourceImage->GetDirection()); 
> 
> return outImage; 
> 
> } 
> 
> 
> 
> 
> THAKS A LOT! 
> 
> Andre
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
> 
_______________________________________________
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