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