00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkSquareImageFilter_h
00018 #define __itkSquareImageFilter_h
00019
00020 #include "itkUnaryFunctorImageFilter.h"
00021
00022 namespace itk
00023 {
00024
00031 namespace Function {
00032
00033 template< class TInput, class TOutput>
00034 class Square
00035 {
00036 public:
00037 typedef typename NumericTraits<TInput>::RealType RealType;
00038 Square() {}
00039 ~Square() {}
00040 bool operator!=( const Square & ) const
00041 {
00042 return false;
00043 }
00044 bool operator==( const Square & other ) const
00045 {
00046 return !(*this != other);
00047 }
00048 inline TOutput operator()( const TInput & A )
00049 {
00050 const RealType ra = static_cast<RealType>( A );
00051 return static_cast<TOutput>( ra * ra );
00052 }
00053 };
00054 }
00055 template <class TInputImage, class TOutputImage>
00056 class ITK_EXPORT SquareImageFilter :
00057 public
00058 UnaryFunctorImageFilter<TInputImage,TOutputImage,
00059 Function::Square< typename TInputImage::PixelType,
00060 typename TOutputImage::PixelType> >
00061 {
00062 public:
00064 typedef SquareImageFilter Self;
00065 typedef UnaryFunctorImageFilter<TInputImage,TOutputImage,
00066 Function::Square< typename TInputImage::PixelType,
00067 typename TOutputImage::PixelType> > Superclass;
00068 typedef SmartPointer<Self> Pointer;
00069 typedef SmartPointer<const Self> ConstPointer;
00070
00072 itkNewMacro(Self);
00073
00075 itkTypeMacro(SquareImageFilter,
00076 UnaryFunctorImageFilter);
00077
00078 #ifdef ITK_USE_CONCEPT_CHECKING
00079
00080 itkConceptMacro(InputHasNumericTraitsCheck,
00081 (Concept::HasNumericTraits<typename TInputImage::PixelType>));
00082 itkConceptMacro(RealTypeMultiplyOperatorCheck,
00083 (Concept::MultiplyOperator<typename NumericTraits<typename TInputImage::PixelType>::RealType>));
00084
00086 #endif
00087
00088 protected:
00089 SquareImageFilter() {}
00090 virtual ~SquareImageFilter() {}
00091
00092 private:
00093 SquareImageFilter(const Self&);
00094 void operator=(const Self&);
00095
00096 };
00097
00098 }
00099
00100
00101 #endif
00102