Hi guys,<br><br>I am confused by the behavior of itk::OrientImageFilter. <br><br>If I re-orient an image from RPI to LPI, the output image is visualized as same as the input file using Slicer3 as the visualization tool.<br>
<br>As I look closer, it appears to me that the filter do the thing below if the input and output both are meta format:<br><br>1. change the orientation of the data stored ( however the AnatomicalOrientation remains unchanged, is it a bug?).
<br>2. change the TransformMatrix.<br><br>To change the orientation of image, a filter may have to do either 1 or 2, preferably 1, because it means Anatomical Orientation. However, since the filter does both 1 and 2, so the visualization seems unchanged.
<br><br>Does somebody know if it is a bug or implemented in purpose? <br><br>The data can be downloaded at <a href="http://www.duke.edu/~kurtzhao/RPI_original.zip">http://www.duke.edu/~kurtzhao/RPI_original.zip</a> and the code is enclosed.
<br><br>Any input is highly appreciated.<br><br>-Kurt<br><br>#include <metaCommand.h><br>#include <itkImageFileWriter.h><br>#include <itkImageFileReader.h><br>#include <itkAnalyzeImageIO.h><br>#include <
itkNiftiImageIO.h><br>#include <itkOrientImageFilter.h><br>#include <itkSpatialOrientation.h><br><br><br><br>int main(int argc, char **argv)<br> {<br><br> const unsigned int Dimension = 3;<br> typedef short PixelType;
<br><br> typedef itk::Image< PixelType, Dimension > ImageType;<br> typedef itk::ImageFileReader< ImageType > ReaderType;<br> typedef itk::ImageIOBase ImageIOBaseType;<br><br>
ReaderType::Pointer reader = ReaderType::New();<br><br> itk::AnalyzeImageIO::Pointer io = itk::AnalyzeImageIO::New();<br><br> std::string inputFileName; <br> inputFileName = "C:/data/formatConversion/RPI_original.mha";
<br><br> reader->SetFileName( inputFileName.c_str() );<br><br><br> try <br> {<br> reader -> Update ( ) ;<br> }<br> catch( itk::ExceptionObject & err )<br> {<br> std::cerr << "ExceptionObject caught !" << std::endl;
<br> std::cerr << err << std::endl;<br> return EXIT_FAILURE;<br> }<br><br> typedef itk::OrientImageFilter<ImageType,ImageType> OrienterType;<br> OrienterType::Pointer orienter = OrienterType::New();
<br> orienter->UseImageDirectionOn();<br> orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_LPI); <br> orienter->SetInput( reader -> GetOutput ( ) );<br> try <br>
{<br> orienter->Update();<br> }<br> catch( itk::ExceptionObject & err )<br> {<br> std::cerr << "ExceptionObject caught !" << std::endl;<br> std::cerr << err << std::endl;
<br> return EXIT_FAILURE;<br> }<br><br> typedef itk::ImageFileWriter < ImageType > WriterType;<br><br> WriterType::Pointer writer = WriterType::New();<br><br> itk::NiftiImageIO::Pointer niftIio = itk::NiftiImageIO::New();
<br><br><br> std::string outputFileName; <br><br> outputFileName = "C:/data/formatConversion/LPI.mha";<br><br> writer ->SetFileName( outputFileName.c_str() );<br><br> writer -> SetInput ( orienter -> GetOutput ( ) ) ;
<br><br> writer -> UseCompressionOn ( ) ;<br><br> try <br> {<br> writer -> Update ( ) ;<br> }<br> catch( itk::ExceptionObject & err )<br> {<br> std::cerr << "ExceptionObject caught !" << std::endl;
<br> std::cerr << err << std::endl;<br> return EXIT_FAILURE;<br> }<br><br> return EXIT_SUCCESS;<br> }<br>