00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkRGBToLuminanceImageFilter.h,v $ 00005 Language: C++ 00006 Date: $Date: 2004/05/10 00:16:11 $ 00007 Version: $Revision: 1.1 $ 00008 00009 Copyright (c) Insight Software Consortium. All rights reserved. 00010 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 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 inline TOutput operator()( const TInput & A ) 00047 { return static_cast<TOutput>( A.GetLuminance() ); } 00048 }; 00049 } 00050 00051 template <class TInputImage, class TOutputImage> 00052 class ITK_EXPORT RGBToLuminanceImageFilter : 00053 public 00054 UnaryFunctorImageFilter<TInputImage,TOutputImage, 00055 Function::RGBToLuminance< 00056 typename TInputImage::PixelType, 00057 typename TOutputImage::PixelType> > 00058 { 00059 public: 00061 typedef RGBToLuminanceImageFilter Self; 00062 typedef UnaryFunctorImageFilter<TInputImage,TOutputImage, 00063 Function::RGBToLuminance< typename TInputImage::PixelType, 00064 typename TOutputImage::PixelType> > Superclass; 00065 typedef SmartPointer<Self> Pointer; 00066 typedef SmartPointer<const Self> ConstPointer; 00067 00069 itkNewMacro(Self); 00070 00071 protected: 00072 RGBToLuminanceImageFilter() {} 00073 virtual ~RGBToLuminanceImageFilter() {} 00074 00075 private: 00076 RGBToLuminanceImageFilter(const Self&); //purposely not implemented 00077 void operator=(const Self&); //purposely not implemented 00078 00079 }; 00080 00081 } // end namespace itk 00082 00083 00084 #endif