1 /*=========================================================================
3 Program: Insight Segmentation & Registration Toolkit
4 Module: $RCSfile: itkFlexibleVectorCastImageFilter.h,v $
6 Date: $Date: 2008-10-17 16:30:53 $
7 Version: $Revision: 1.16 $
9 Copyright (c) Insight Software Consortium. All rights reserved.
10 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
17 #ifndef __itkFlexibleVectorCastImageFilter_h
18 #define __itkFlexibleVectorCastImageFilter_h
20 #include "itkUnaryFunctorImageFilter.h"
21 #include "itkNumericTraitsFixedArrayPixel.h"
26 /** \class FlexibleVectorCastImageFilter
28 * \brief Casts input vector pixels to output vector pixel type.
30 * This filter is templated over the input image type and
33 * The filter expect both images to have the same number of dimensions,
34 * and that both the input and output have itk::Vector pixel types
35 * of the same VectorDimension.
39 * \ingroup IntensityImageFilters Multithreaded
43 template< class TInput, class TOutput>
44 class FlexibleVectorCast
47 FlexibleVectorCast() {}
48 ~FlexibleVectorCast() {}
49 bool operator!=( const FlexibleVectorCast & ) const
53 bool operator==( const FlexibleVectorCast & other ) const
55 return !(*this != other);
57 inline TOutput operator()( const TInput & A ) const
59 typedef typename TOutput::ValueType OutputValueType;
63 for( k = 0; k < TOutput::Dimension && k < TInput::Dimension; k++ )
65 value[k] = static_cast<OutputValueType>( A[k] );
68 for (; k < TOutput::Dimension; k++)
76 template <class TInputImage, class TOutputImage = itk::Vector<float, 3> >
77 class ITK_EXPORT FlexibleVectorCastImageFilter :
79 UnaryFunctorImageFilter<TInputImage,TOutputImage,
80 Functor::FlexibleVectorCast< typename TInputImage::PixelType,
81 typename TOutputImage::PixelType> >
84 /** Standard class typedefs. */
85 typedef FlexibleVectorCastImageFilter Self;
86 typedef UnaryFunctorImageFilter<
87 TInputImage,TOutputImage,
88 Functor::FlexibleVectorCast< typename TInputImage::PixelType,
89 typename TOutputImage::PixelType> > Superclass;
90 typedef SmartPointer<Self> Pointer;
91 typedef SmartPointer<const Self> ConstPointer;
93 /** Method for creation through the object factory. */
96 /** Runtime information support. */
97 itkTypeMacro(FlexibleVectorCastImageFilter,
98 UnaryFunctorImageFilter);
101 FlexibleVectorCastImageFilter() {}
102 virtual ~FlexibleVectorCastImageFilter() {}
105 FlexibleVectorCastImageFilter(const Self&); //purposely not implemented
106 void operator=(const Self&); //purposely not implemented
110 } // end namespace itk