18 #ifndef __itkVectorImageToMultiVolumeImageFilter_hxx 19 #define __itkVectorImageToMultiVolumeImageFilter_hxx 24 #include "itkImageRegionIteratorWithIndex.h" 30 template <
class TInputPixelType,
class TOutputPixelType,
unsigned int VImageDimension>
40 unsigned int vectorDimension = inputPtr->GetNumberOfComponentsPerPixel();
41 typename OutputImageType::RegionType outRegion = outputPtr->GetLargestPossibleRegion();
42 typename OutputImageType::SizeType outSize = outRegion.GetSize();
43 outSize[MultiVolumeImageDimension-1] = vectorDimension;
44 outRegion.SetSize(outSize);
45 outputPtr->SetRegions(outRegion);
48 template <
class TInputPixelType,
class TOutputPixelType,
unsigned int VImageDimension>
56 outputPtr->Allocate();
58 ImageRegionIteratorWithIndex<InputImageType> inputIt(inputPtr, inputPtr->GetLargestPossibleRegion());
61 unsigned int vectorDimension = inputPtr->GetNumberOfComponentsPerPixel();
62 inputPixel.SetSize( vectorDimension );
63 typename InputImageType::IndexType inputIndex;
64 typename OutputImageType::IndexType outputIndex;
66 while(!inputIt.IsAtEnd())
68 inputIndex = inputIt.GetIndex();
69 inputPixel = inputIt.Get();
71 for (
unsigned int i = 0; i < VectorImageDimension; i++ )
73 outputIndex[i] = inputIndex[i];
76 for (
unsigned int i = 0; i < vectorDimension; i++ )
78 outputIndex[MultiVolumeImageDimension-1] = i;
79 outputPtr->SetPixel(outputIndex, inputPixel[i]);
86 template <
class TInputPixelType,
class TOutputPixelType,
unsigned int VImageDimension>
90 Superclass::PrintSelf(os, indent);
91 PrintVar1(this->GetInput(), this->GetInput(), os<<indent <<
"VectorImage");
92 PrintVar1(this->GetOutput(), this->GetOutput(), os<<indent <<
"MultiVolumeImage");
95 template <
class ScalarType,
unsigned Dim>
97 VectorToMultiVolumeImage (
const SmartPointer<VectorImage<ScalarType,Dim> >& image1, SmartPointer<Image<ScalarType, Dim+1> >& image2 )
100 typename ConvertorType::Pointer convertor = ConvertorType::New();
101 convertor->SetInput(image1);
103 image2 = convertor->GetOutput();
#define PrintVar1(cond, var, os)
virtual void GenerateData() ITK_OVERRIDE
virtual void GenerateOutputInformation() ITK_OVERRIDE
convert VectorImage<TOutputPixelType, VImageDimension> to Image<TInputPixelType, VImageDimension+1> ...
void CopyImageInformation(const SmartPointer< ImageWithInfoType > &imageFrom, SmartPointer< ImageType > &imageTo)
OutputImageType::Pointer OutputImagePointer
InputImageType::Pointer InputImagePointer
void VectorToMultiVolumeImage(const SmartPointer< VectorImage< ScalarType, Dim > > &image1, SmartPointer< Image< ScalarType, Dim+1 > > &image2)
VectorImage< TOutputPixelType, VectorImageDimension > InputImageType
void PrintSelf(std::ostream &os, Indent indent) const ITK_OVERRIDE
InputImageType::PixelType InputImagePixelType