14 #ifndef __itkVTKImageDataToImageFilter_hxx 15 #define __itkVTKImageDataToImageFilter_hxx 19 #include "vtkDoubleArray.h" 20 #include "vtkPointData.h" 21 #include "vtkVersion.h" 29 template <
class TOutputImage>
39 template <
class TOutputImage>
44 if ( inputImage != m_Image )
55 template <
class TOutputImage>
61 vtkSmartPointer<vtkDoubleArray> data
62 = vtkSmartPointer<vtkDoubleArray>::New();
63 data =
static_cast<vtkDoubleArray *
>(
64 m_Image->GetPointData()->GetScalars() );
67 int inputSize[Dimension];
68 double inputSpacing[Dimension];
69 double inputOrigin[Dimension];
70 m_Image->GetDimensions(inputSize);
71 m_Image->GetSpacing(inputSpacing);
72 m_Image->GetOrigin(inputOrigin);
73 int numberOfComponentsPerPixel
74 = m_Image->GetPointData()->GetNumberOfComponents();
84 outputPixel.SetSize( numberOfComponentsPerPixel );
86 for (
unsigned int k=0; k<Dimension; k++)
88 outputSize[k] = inputSize[k];
89 outputSpacing[k] = inputSpacing[k];
90 outputOrigin[k] = inputOrigin[k];
95 outputRegion.SetSize(outputSize);
96 outputRegion.SetIndex(outputIndex);
98 outputImage->SetSpacing(outputSpacing);
99 outputImage->SetRegions(outputRegion);
100 outputImage->SetOrigin(outputOrigin);
101 outputImage->SetNumberOfComponentsPerPixel(numberOfComponentsPerPixel);
103 outputImage->Allocate();
105 outputImage->FillBuffer(outputPixel);
109 outputIt(outputImage, outputImage->GetLargestPossibleRegion());
111 outputIt.GoToBegin();
117 while( !outputIt.IsAtEnd() )
119 dataEntry = data->GetTuple(i);
120 for (
unsigned int k = 0; k < numberOfComponentsPerPixel; k++)
122 outputPixel[k] = dataEntry[k];
124 outputIt.Set( outputPixel );
ImageRegionIterator< OutputImageType > OutputImageIteratorType
OutputImageType::Pointer OutputImagePointer
OutputImageType::RegionType OutputRegionType
OutputImageType::SpacingType OutputSpacingType
OutputImageType::PixelType OutputPixelType
VTKImageDataToImageFilter()
virtual void GenerateData() ITK_OVERRIDE
void SetInputData(vtkImageData *)
OutputImageType::SizeType OutputSizeType
OutputImageType::IndexType OutputIndexType
OutputImageType::PointType OutputPointType