18 #ifndef __itkMultiVolumeImageToVectorImageFilter_hxx 19 #define __itkMultiVolumeImageToVectorImageFilter_hxx 24 #include "itkImageRegionIteratorWithIndex.h" 30 template <
class TInputPixelType,
class TOutputPixelType,
unsigned int VImageDimension>
36 itk::CopyImageInformation<InputImageType, OutputImageType>(inputPtr, outputPtr);
37 typename InputImageType::RegionType inputRegion = inputPtr->GetLargestPossibleRegion();
38 typename InputImageType::SizeType inputImageSize = inputRegion.GetSize();
39 outputPtr->SetNumberOfComponentsPerPixel( inputImageSize[MultiVolumeImageDimension-1] );
42 template <
class TInputPixelType,
class TOutputPixelType,
unsigned int VImageDimension>
50 outputPtr->Allocate();
52 ImageRegionIteratorWithIndex<OutputImageType> outputIt(outputPtr, outputPtr->GetLargestPossibleRegion());
55 unsigned int vectorDimension = outputPtr->GetNumberOfComponentsPerPixel();
56 outputPixel.SetSize( vectorDimension );
57 typename InputImageType::IndexType inputIndex;
58 typename OutputImageType::IndexType outputIndex;
60 while(!outputIt.IsAtEnd())
62 outputIndex = outputIt.GetIndex();
63 for (
int i = 0; i < VectorImageDimension; i += 1 )
65 inputIndex[i] = outputIndex[i];
67 for (
int i = 0; i < vectorDimension; i += 1 )
69 inputIndex[MultiVolumeImageDimension-1] = i;
70 outputPixel[i] = (TOutputPixelType) inputPtr->GetPixel(inputIndex);
72 outputIt.Set(outputPixel);
77 template <
class TInputPixelType,
class TOutputPixelType,
unsigned int VImageDimension>
81 Superclass::PrintSelf(os, indent);
82 PrintVar1(this->GetInput(), this->GetInput(), os<<indent <<
"MultiVolumeImage");
83 PrintVar1(this->GetOutput(), this->GetOutput(), os<<indent <<
"VectorImage");
86 template <
class ScalarType,
unsigned Dim>
88 MultiVolumeToVectorImage (
const SmartPointer<Image<ScalarType, Dim+1> >& image1, SmartPointer<VectorImage<ScalarType,Dim> >& image2 )
91 typename ConvertorType::Pointer convertor = ConvertorType::New();
92 convertor->SetInput(image1);
94 image2 = convertor->GetOutput();
InputImageType::Pointer InputImagePointer
#define PrintVar1(cond, var, os)
virtual void GenerateOutputInformation() ITK_OVERRIDE
void MultiVolumeToVectorImage(const SmartPointer< Image< ScalarType, Dim+1 > > &image1, SmartPointer< VectorImage< ScalarType, Dim > > &image2)
void PrintSelf(std::ostream &os, Indent indent) const ITK_OVERRIDE
convert Image<TInputPixelType, VImageDimension+1> to VectorImage<TOutputPixelType, VImageDimension>
Image< TInputPixelType, MultiVolumeImageDimension > InputImageType
OutputImageType::PixelType OutputImagePixelType
OutputImageType::Pointer OutputImagePointer
virtual void GenerateData() ITK_OVERRIDE