]> Creatis software - cpPlugins.git/blob - lib/cpExtensions/Algorithms/RGBToSingleChannelFunctor.h
815b936124cab9e2f8a1fdb0eb2386f6a957098a
[cpPlugins.git] / lib / cpExtensions / Algorithms / RGBToSingleChannelFunctor.h
1 // -------------------------------------------------------------------------
2 // @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
3 // -------------------------------------------------------------------------
4
5 #ifndef __cpExtensions__Algorithms__RGBToSingleChannelFunctor__h__
6 #define __cpExtensions__Algorithms__RGBToSingleChannelFunctor__h__
7
8 #include <itkFunctionBase.h>
9 #include <itkRGBPixel.h>
10
11 namespace cpExtensions
12 {
13   namespace Algorithms
14   {
15     /**
16      */
17     template< class _TScalar >
18     class RGBToSingleChannelFunctor
19       : public itk::FunctionBase< itk::RGBPixel< _TScalar >, _TScalar >
20     {
21     public:
22       typedef _TScalar                             TScalar;
23       typedef itk::RGBPixel< _TScalar >            TPixel;
24       typedef RGBToSingleChannelFunctor            Self;
25       typedef itk::FunctionBase< TPixel, TScalar > Superclass;
26       typedef itk::SmartPointer< Self >            Pointer;
27       typedef itk::SmartPointer< const Self >      ConstPointer;
28
29       enum ChannelType
30       {
31         Red = 0,
32         Green,
33         Blue,
34         Hue,
35         Saturation,
36         Value
37       };
38
39     public:
40       itkNewMacro( Self );
41       itkTypeMacro( RGBToSingleChannelFunctor, itkFunctionBase );
42
43       itkGetConstMacro( Channel, ChannelType );
44       itkSetMacro( Channel, ChannelType );
45
46     public:
47       bool IsChannelRed( ) const;
48       bool IsChannelGreen( ) const;
49       bool IsChannelBlue( ) const;
50       bool IsChannelHue( ) const;
51       bool IsChannelSaturation( ) const;
52       bool IsChannelValue( ) const;
53
54       void SetChannelToRed( );
55       void SetChannelToGreen( );
56       void SetChannelToBlue( );
57       void SetChannelToHue( );
58       void SetChannelToSaturation( );
59       void SetChannelToValue( );
60
61       virtual TScalar Evaluate( const TPixel& pixel ) const override;
62
63     protected:
64       RGBToSingleChannelFunctor( );
65       virtual ~RGBToSingleChannelFunctor( );
66
67     private:
68       // Purposely not implemented.
69       RGBToSingleChannelFunctor( const Self& );
70       void operator=( const Self& );
71
72     protected:
73       ChannelType m_Channel;
74     };
75
76   } // ecapseman
77
78 } // ecapseman
79
80 #ifndef ITK_MANUAL_INSTANTIATION
81 #  include <cpExtensions/Algorithms/RGBToSingleChannelFunctor.hxx>
82 #endif // ITK_MANUAL_INSTANTIATION
83
84 #endif // __cpExtensions__Algorithms__RGBToSingleChannelFunctor__h__
85
86 // eof - $RCSfile$