X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpExtensions%2FAlgorithms%2FRGBToSingleChannelFunctor.h;fp=lib%2FcpExtensions%2FAlgorithms%2FRGBToSingleChannelFunctor.h;h=815b936124cab9e2f8a1fdb0eb2386f6a957098a;hb=9947c770b79585f718013305a956cf9473a4e0b2;hp=0000000000000000000000000000000000000000;hpb=9af34b55ea1d60eef3608aede00f9ef5a16dccdf;p=cpPlugins.git diff --git a/lib/cpExtensions/Algorithms/RGBToSingleChannelFunctor.h b/lib/cpExtensions/Algorithms/RGBToSingleChannelFunctor.h new file mode 100644 index 0000000..815b936 --- /dev/null +++ b/lib/cpExtensions/Algorithms/RGBToSingleChannelFunctor.h @@ -0,0 +1,86 @@ +// ------------------------------------------------------------------------- +// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co) +// ------------------------------------------------------------------------- + +#ifndef __cpExtensions__Algorithms__RGBToSingleChannelFunctor__h__ +#define __cpExtensions__Algorithms__RGBToSingleChannelFunctor__h__ + +#include +#include + +namespace cpExtensions +{ + namespace Algorithms + { + /** + */ + template< class _TScalar > + class RGBToSingleChannelFunctor + : public itk::FunctionBase< itk::RGBPixel< _TScalar >, _TScalar > + { + public: + typedef _TScalar TScalar; + typedef itk::RGBPixel< _TScalar > TPixel; + typedef RGBToSingleChannelFunctor Self; + typedef itk::FunctionBase< TPixel, TScalar > Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + enum ChannelType + { + Red = 0, + Green, + Blue, + Hue, + Saturation, + Value + }; + + public: + itkNewMacro( Self ); + itkTypeMacro( RGBToSingleChannelFunctor, itkFunctionBase ); + + itkGetConstMacro( Channel, ChannelType ); + itkSetMacro( Channel, ChannelType ); + + public: + bool IsChannelRed( ) const; + bool IsChannelGreen( ) const; + bool IsChannelBlue( ) const; + bool IsChannelHue( ) const; + bool IsChannelSaturation( ) const; + bool IsChannelValue( ) const; + + void SetChannelToRed( ); + void SetChannelToGreen( ); + void SetChannelToBlue( ); + void SetChannelToHue( ); + void SetChannelToSaturation( ); + void SetChannelToValue( ); + + virtual TScalar Evaluate( const TPixel& pixel ) const override; + + protected: + RGBToSingleChannelFunctor( ); + virtual ~RGBToSingleChannelFunctor( ); + + private: + // Purposely not implemented. + RGBToSingleChannelFunctor( const Self& ); + void operator=( const Self& ); + + protected: + ChannelType m_Channel; + }; + + } // ecapseman + +} // ecapseman + +#ifndef ITK_MANUAL_INSTANTIATION +# include +#endif // ITK_MANUAL_INSTANTIATION + +#endif // __cpExtensions__Algorithms__RGBToSingleChannelFunctor__h__ + +// eof - $RCSfile$