11 #ifndef __itkComposeVectorImageFilter_hxx 12 #define __itkComposeVectorImageFilter_hxx 15 #include "itkImageRegionIterator.h" 16 #include "itkProgressReporter.h" 21 template<
typename TInputImage,
typename TOutputImage >
26 int nbOfComponents = NumericTraits<OutputPixelType>::GetLength(p);
27 nbOfComponents =
std::max( 1, nbOfComponents );
28 this->SetNumberOfRequiredInputs( nbOfComponents );
32 template<
typename TInputImage,
typename TOutputImage >
38 this->SetNthInput( 0, const_cast< InputImageType * >( image1 ) );
42 template<
typename TInputImage,
typename TOutputImage >
48 this->SetNthInput( 1, const_cast< InputImageType * >( image2 ) );
52 template<
typename TInputImage,
typename TOutputImage >
58 this->SetNthInput( 2, const_cast< InputImageType * >( image3 ) );
62 template<
typename TInputImage,
typename TOutputImage >
70 this->Superclass::GenerateOutputInformation();
74 for (
int i = 0; i < this->GetNumberOfIndexedInputs(); ++i )
77 n += inputImage->GetNumberOfComponentsPerPixel();
79 output->SetNumberOfComponentsPerPixel( n );
83 template<
typename TInputImage,
typename TOutputImage >
90 const unsigned int numberOfInputs = this->GetNumberOfIndexedInputs();
93 for (
unsigned int i = 0; i < numberOfInputs; i++ )
95 InputImageType *input = itkDynamicCastInDebugMode< InputImageType * >
96 (this->ProcessObject::GetInput(i) );
99 itkExceptionMacro(<<
"Input " << i <<
" not set!");
103 region = input->GetLargestPossibleRegion();
105 else if ( input->GetLargestPossibleRegion() != region )
107 itkExceptionMacro(<<
"All Inputs must have the same dimensions.");
113 template<
typename TInputImage,
typename TOutputImage >
117 ThreadIdType threadId)
119 ProgressReporter progress(
this, threadId, outputRegionForThread.GetNumberOfPixels() );
121 typename OutputImageType::Pointer outputImage =
124 ImageRegionIterator< OutputImageType > oit(outputImage, outputRegionForThread);
129 for (
unsigned int i = 0; i < this->GetNumberOfIndexedInputs(); i++ )
135 inputItContainer.push_back(iit);
139 NumericTraits<OutputPixelType>::SetLength( pix, outputImage->GetNumberOfComponentsPerPixel() );
140 while ( !oit.IsAtEnd() )
142 ComputeOutputPixel( pix, inputItContainer );
145 progress.CompletedPixel();
std::vector< InputIteratorType > InputIteratorContainerType
virtual void GenerateOutputInformation(void) ITK_OVERRIDE
void SetInput3(const InputImageType *image3)
TOutputImage OutputImageType
TInputImage InputImageType
const T & max(const T &a, const T &b)
Return the maximum between a and b.
void SetInput1(const InputImageType *image1)
virtual void BeforeThreadedGenerateData() ITK_OVERRIDE
ImageRegionConstIterator< InputImageType > InputIteratorType
virtual void ThreadedGenerateData(const RegionType &outputRegionForThread, ThreadIdType) ITK_OVERRIDE
ComposeVectorImageFilter()
void SetInput2(const InputImageType *image2)
InputImageType::RegionType RegionType
OutputImageType::PixelType OutputPixelType