[Insight-users] The behavior of itk::OrientImageFilter
kurt Zhao
kurtzhao at gmail.com
Fri Mar 2 15:46:54 EST 2007
Hi guys,
I am confused by the behavior of itk::OrientImageFilter.
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.
As I look closer, it appears to me that the filter do the thing below if the
input and output both are meta format:
1. change the orientation of the data stored ( however the
AnatomicalOrientation remains unchanged, is it a bug?).
2. change the TransformMatrix.
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.
Does somebody know if it is a bug or implemented in purpose?
The data can be downloaded at
http://www.duke.edu/~kurtzhao/RPI_original.zipand the code is
enclosed.
Any input is highly appreciated.
-Kurt
#include <metaCommand.h>
#include <itkImageFileWriter.h>
#include <itkImageFileReader.h>
#include <itkAnalyzeImageIO.h>
#include <itkNiftiImageIO.h>
#include <itkOrientImageFilter.h>
#include <itkSpatialOrientation.h>
int main(int argc, char **argv)
{
const unsigned int Dimension = 3;
typedef short PixelType;
typedef itk::Image< PixelType, Dimension > ImageType;
typedef itk::ImageFileReader< ImageType > ReaderType;
typedef itk::ImageIOBase ImageIOBaseType;
ReaderType::Pointer reader = ReaderType::New();
itk::AnalyzeImageIO::Pointer io = itk::AnalyzeImageIO::New();
std::string inputFileName;
inputFileName = "C:/data/formatConversion/RPI_original.mha";
reader->SetFileName( inputFileName.c_str() );
try
{
reader -> Update ( ) ;
}
catch( itk::ExceptionObject & err )
{
std::cerr << "ExceptionObject caught !" << std::endl;
std::cerr << err << std::endl;
return EXIT_FAILURE;
}
typedef itk::OrientImageFilter<ImageType,ImageType> OrienterType;
OrienterType::Pointer orienter = OrienterType::New();
orienter->UseImageDirectionOn();
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_LPI);
orienter->SetInput( reader -> GetOutput ( ) );
try
{
orienter->Update();
}
catch( itk::ExceptionObject & err )
{
std::cerr << "ExceptionObject caught !" << std::endl;
std::cerr << err << std::endl;
return EXIT_FAILURE;
}
typedef itk::ImageFileWriter < ImageType > WriterType;
WriterType::Pointer writer = WriterType::New();
itk::NiftiImageIO::Pointer niftIio = itk::NiftiImageIO::New();
std::string outputFileName;
outputFileName = "C:/data/formatConversion/LPI.mha";
writer ->SetFileName( outputFileName.c_str() );
writer -> SetInput ( orienter -> GetOutput ( ) ) ;
writer -> UseCompressionOn ( ) ;
try
{
writer -> Update ( ) ;
}
catch( itk::ExceptionObject & err )
{
std::cerr << "ExceptionObject caught !" << std::endl;
std::cerr << err << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20070302/896c62de/attachment.html
More information about the Insight-users
mailing list