[ITK] change orientation of images with OrientImageFilter
Andras Lasso
lasso at queensu.ca
Tue Jul 29 10:53:00 EDT 2014
We experienced the same issue in Slicer (see http://www.na-mic.org/Bug/view.php?id=2173). ITK ignores anatomical orientation in MetaIO images, while ITK properly uses anatomical orientation information in some other file formats (e.g., NRRD).
Andras
From: Butlers Home<mailto:butlershomecoffee at gmail.com>
Sent: Tuesday, July 29, 2014 10:13 AM
To: community at itk.org<mailto:community at itk.org>
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/7a56704c/attachment-0002.html>
More information about the Community
mailing list