12 #ifndef __itkVectorImageChannelFilter_hxx 13 #define __itkVectorImageChannelFilter_hxx 16 #include "itkVectorIndexSelectionCastImageFilter.h" 22 template<
class TInputImage,
class TOutputImage,
class TFilter >
29 template<
class TInputImage,
class TOutputImage,
class TFilter >
30 typename LightObject::Pointer
34 typename LightObject::Pointer loPtr = Superclass::InternalClone();
39 itkExceptionMacro(<<
"downcast to type " << this->GetNameOfClass()<<
" failed.");
41 rval->m_Filter = m_Filter->Clone();
45 template<
class TInputImage,
class TOutputImage,
class TFilter >
50 Superclass::PrintSelf(os, indent);
52 m_Filter->Print(os<<indent <<
"m_Filter =\n");
55 template<
class TInputImage,
class TOutputImage,
class TFilter >
61 typename TInputImage::ConstPointer inputImage = this->GetInput();
62 int N = inputImage->GetNumberOfComponentsPerPixel();
64 typedef typename TFilter::OutputImageType FilterOutputImageType;
66 typename ComposeImageFilterType::Pointer composeImageFilter = ComposeImageFilterType::New();
68 typedef itk::VectorIndexSelectionCastImageFilter<TInputImage, typename TFilter::InputImageType> IndexSelectionType;
70 for (
int i = 0; i < N; ++i )
72 typename IndexSelectionType::Pointer indexSelectionFilter = IndexSelectionType::New();
73 indexSelectionFilter->SetIndex(i);
74 indexSelectionFilter->SetInput(inputImage);
77 typename TFilter::Pointer filterCopy = m_Filter->Clone();
78 filterCopy->SetInput(indexSelectionFilter->GetOutput());
80 typename FilterOutputImageType::Pointer out = filterCopy->GetOutput();
82 composeImageFilter->SetInput(i, filterCopy->GetOutput());
85 composeImageFilter->Update();
86 typename OutputImageType::Pointer outputImage = composeImageFilter->GetOutput();
88 this->GraftOutput(outputImage);
TInputImage and TOutputImage are VectorImage, TFilter is an image filter which works for itk::Image...
virtual void PrintSelf(std::ostream &os, Indent indent) const ITK_OVERRIDE
ComposeVectorImageFilter combine several vector images into a vector image.
ImageToImageFilter< TInputImage, TOutputImage > Superclass
#define utlException(cond, expout)
VectorImageChannelFilter()
SmartPointer< Self > Pointer
void GenerateData() ITK_OVERRIDE
LightObject::Pointer InternalClone() const ITK_OVERRIDE