1 /*===================================================================
3 The Medical Imaging Interaction Toolkit (MITK)
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
13 See LICENSE.txt or http://www.mitk.org for details.
15 ===================================================================*/
17 #ifndef __itkVectorImageToImageFilter_txx
18 #define __itkVectorImageToImageFilter_txx
24 #define _USE_MATH_DEFINES
27 #include "itkImageRegionIterator.h"
33 template< class TPixelType >
34 VectorImageToImageFilter< TPixelType >
35 ::VectorImageToImageFilter()
38 this->SetNumberOfRequiredInputs( 1 );
41 template< class TPixelType >
43 VectorImageToImageFilter< TPixelType >
46 typename OutputImageType::Pointer outputImage =
47 static_cast< OutputImageType * >(this->ProcessObject::GetOutput(0));
49 outputImage->SetSpacing(this->GetInput()->GetSpacing());
50 outputImage->SetOrigin(this->GetInput()->GetOrigin());
51 outputImage->SetRegions(this->GetInput()->GetLargestPossibleRegion());
52 outputImage->Allocate();
54 ImageRegionIterator< OutputImageType > oit(outputImage, outputImage->GetLargestPossibleRegion());
58 typename InputImageType::Pointer inputImagePointer = NULL;
59 inputImagePointer = static_cast< InputImageType * >( this->ProcessObject::GetInput(0) );
61 ImageRegionIterator <InputImageType> git( inputImagePointer, inputImagePointer->GetLargestPossibleRegion() );
63 while( !git.IsAtEnd() )
65 oit.Set(git.Get()[m_Index]);
71 template< class TPixelType >
72 void VectorImageToImageFilter< TPixelType >::PrintSelf(std::ostream& os, Indent indent) const
74 Superclass::PrintSelf(os,indent);
79 #endif // __itkVectorImageToImageFilter_txx