[ITK] change orientation of images with OrientImageFilter

Butlers Home butlershomecoffee at gmail.com
Tue Jul 29 10:13:33 EDT 2014


I would like to know how I can change the orientation of two 3D images.
Scenario:
- both images are .mha
- one image has RAI as the initial orientation
- 2nd image has LPS as the initial orientation

I would like to set the same orientation RAI for both images before
processing them (i.e., registering them in my case). With the below
mentioned code I manage to change the orientation specified textually in
the .mha files but visually they do not change. Why is that? Is the
orientation changing just within the header specifications without actually
changing the visualization part? For visualization I used ITK-SNAP.

Here is a code snippet from what I do:

[...]

typedef itk::ImageFileReader< ImageType2 > ImageReaderType1;
typedef itk::ImageFileReader< ImageType1 > ImageReaderType2;

ImageReaderType1::Pointer imReader1 = ImageReaderType1::New();
ImageReaderType2::Pointer imReader2 = ImageReaderType2::New();

imReader1->SetFileName("im1.mha");
imReader2->SetFileName("im2.mha");

imReader1->Update();

// set both images to same orientation

// orientation filter for 1st image
itk::OrientImageFilter<ImageType1, ImageType1>::Pointer orienter1 =
itk::OrientImageFilter<ImageType1, ImageType1>::New();
orienter1->UseImageDirectionOn();
orienter1->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_RAI);
orienter1->SetInput(imReader1->GetOutput());
orienter1->Update();

// orientation filter for 2nd image
itk::OrientImageFilter<ImageType2, ImageType2>::Pointer orienter2 =
itk::OrientImageFilter<ImageType2, ImageType2>::New();
orienter2->UseImageDirectionOn();
orienter2->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_RAI);
orienter2->SetInput(imReader2->GetOutput());
orienter2->Update();

[...]

I tried not using the cosine-based approach, i.e., use the
itk::AnalyzeImageIO class together with itk::ExposeMetaData<>() but for
some unknown reason, the orientation is not determined appropriately. I
would also prefer not using them at all because, as far as I understood,
they are deprecated.

Thank you.

Best regards,
--
Butlers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20140729/8149fa2f/attachment.html>


More information about the Community mailing list