1 #ifndef itkPluginUtilities_h 2 #define itkPluginUtilities_h 5 #include <itkContinuousIndex.h> 7 #include <itkImageFileReader.h> 19 ImageIOBase::IOPixelType &pixelType,
20 ImageIOBase::IOComponentType &componentType)
22 typedef itk::Image<unsigned char, 3> ImageType;
23 itk::ImageFileReader<ImageType>::Pointer imageReader =
24 itk::ImageFileReader<ImageType>::New();
25 imageReader->SetFileName(fileName.c_str());
26 imageReader->UpdateOutputInformation();
28 pixelType = imageReader->GetImageIO()->GetPixelType();
29 componentType = imageReader->GetImageIO()->GetComponentType();
35 std::vector<ImageIOBase::IOPixelType> &pixelTypes,
36 std::vector<ImageIOBase::IOComponentType> &componentTypes)
39 componentTypes.clear();
42 for (std::vector<std::string>::size_type i = 0; i < fileNames.size(); i++)
44 ImageIOBase::IOPixelType pixelType;
45 ImageIOBase::IOComponentType componentType;
50 pixelTypes.push_back(pixelType);
51 componentTypes.push_back(componentType);
60 typename T::PointType fixedCenter;
62 itk::ContinuousIndex<double,T::ImageDimension> centerIndex;
63 typename T::SizeType size = fixed->GetLargestPossibleRegion().GetSize();
64 for (
unsigned int i = 0; i < T::ImageDimension; i++)
66 centerIndex[i] =
static_cast<double>((size[i]-1)/2.0);
68 fixed->TransformContinuousIndexToPhysicalPoint(centerIndex, fixedCenter);
72 typename T::PointType movingCenter;
74 itk::ContinuousIndex<double,T::ImageDimension> centerIndex;
75 typename T::SizeType size = moving->GetLargestPossibleRegion().GetSize();
76 for (
unsigned i = 0; i < T::ImageDimension; i++)
78 centerIndex[i] =
static_cast<double>((size[i]-1)/2.0);
80 moving->TransformContinuousIndexToPhysicalPoint(centerIndex, movingCenter);
83 for (
unsigned int j = 0; j < fixedCenter.Size(); j++)
85 origin[j] = moving->GetOrigin()[j] - (movingCenter[j] - fixedCenter[j]);
void GetImageTypes(std::vector< std::string > fileNames, std::vector< ImageIOBase::IOPixelType > &pixelTypes, std::vector< ImageIOBase::IOComponentType > &componentTypes)
Get the PixelTypes and ComponentTypes from fileNames.
Simplified inverse ITK transforms.
void GetImageType(std::string fileName, ImageIOBase::IOPixelType &pixelType, ImageIOBase::IOComponentType &componentType)
Get the PixelType and ComponentType from fileName.
void AlignVolumeCenters(T *fixed, T *moving, typename T::PointType &origin)