[Insight-users] setSpacing() Ignored writing to files
Luis Ibanez
luis.ibanez at kitware.com
Sat Jan 26 16:50:54 EST 2008
Hi Felix,
My suggestion:
a) Make a backup of your code
b) Hide the backup in the corner of a dark room
c) Delete your current code
d) Forget everything you have done so far
e) Start from scratch
From your email it seems that you are
1) Working with 2D images of plants
2) Performing registration with these images
Is that right ?
If so, let's go from the beginning:
A) What is the image modality that you
are using ?
- Microscopy ?
- Satellite images of forest ?
- Video cameras ?
B) It seems that you have some freedom
to choose your image file format.
Is that right ?
If so we suggest you to use one of
the following:
a) MetaImage .mha
b) Nifti .nii
c) Nrrd .nrrd
e) VTK .vtk
C) Before you attempt to do any registration,
you should verify that you are able to
read and write your images, and preserve
the information related to:
- Image Origin
- Image Spacing
- Image Orientation
DO NOT Attempt to do any registration until
you are sure that you have mastered the above.
D) Once you are ready for registration you
should first read the "Image Registration"
chapter of the ITK Software Guide
http://www.itk.org/ItkSoftwareGuide.pdf
E) You must start by using a proper Transform
initialization. The error that you were
getting from the MeanSquareMetric is usually
due to a poor initialization of the Transform.
Please let us know your answers to the questions above,
and from there we will be able to advice you on a proper
way to setup your image registration problem.
Regards,
Luis
------------------------
Felix Bollenbeck wrote:
> Hi Bill,
>
> i couldnt get along with the ChangeInformationImageFilter as suggested:
>
> I used ChangeInformationImageFilter to set both moving and fixed image
> (only fixed image snipped) to unit-spacing as below
>
> typedef itk::ChangeInformationImageFilter<FixedImageType>
> SpacingFilterType;
> SpacingFilterType::Pointer fixedSpacingFilter= SpacingFilterType::New();
> fixedSpacingFilter->ChangeSpacingOn();
> fixedSpacingFilter->SetInput(fixedImageReader->GetOutput());
> double unitSpacing[2];
> unitSpacing[0] = 1.0;
> unitSpacing[1] = 1.0;
> fixedSpacingFilter->SetOutputSpacing(unitSpacing);
> fixedSpacingFilter->Update();
> FixedImageType::Pointer fixedImage=fixedSpacingFilter->GetOutput();
>
> However doesnt seem to work
> /
> SIZE spacing-fixed 1 1 # ok
> SIZE spacing-moving 1 1 //# ok/
> /0 5938.29 [5.41628, 800, 600, 13.8069, -2.2433]
> 1 12.1176 [10.7422, 798.529, 591.101, 22.6854, -8.28141]
> ExceptionObject caught !
>
> itk::ExceptionObject (0xbb8720)
>
> ...
>
> File:
> /home/felix/Desktop/InsightToolkit-3.4.0/Code/Algorithms/itkMeanSquaresImageToImageMetric.txx
>
> Line: 369
> Description: itk::ERROR: MeanSquaresImageToImageMetric(0xba11d0): All
> the points mapped to outside of the moving image/
>
> which means something with the set spacing is completely wrong-but what?
> -Im clueless.
>
> Setting the spacing of the written out-image is ignored, as you said. I
> dont see any workarround.
>
> I also tried to set the pixel-res in the data generation side, to match
> ITK's default [1 1] spacing, obtaining different values than I expected,
> which should be due to the inch/mm confusion-Ill check on that.
>
> But i would rather like to handle this on the ITK side. Would you
> perhaps also suggest the use of a different file format? Im not working
> with medical images (but plants) so changing image properties is not
> that critical to me.
>
> Thanks in advance & Best regards,
>
> Felix.
>
More information about the Insight-users
mailing list