]> Creatis software - cpPlugins.git/blob - lib/cpExtensions/Algorithms/RGBToRGBFunction.h
...
[cpPlugins.git] / lib / cpExtensions / Algorithms / RGBToRGBFunction.h
1 // -------------------------------------------------------------------------
2 // @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
3 // -------------------------------------------------------------------------
4
5 #ifndef __CPEXTENSIONS__ALGORITHMS__RGBTORGBFUNCTION__H__
6 #define __CPEXTENSIONS__ALGORITHMS__RGBTORGBFUNCTION__H__
7
8 #include <itkRGBPixel.h>
9 #include <itkMatrix.h>
10 #include <itkVector.h>
11
12 namespace cpExtensions
13   {
14     namespace Algorithms
15     {
16       /**
17        */
18       template< class O >
19       struct RGBToRGBFunction
20       {
21         typedef RGBToRGBFunction  Self;
22         typedef itk::Vector< O, 3 > TOutPixel;
23
24         template< class Tr, class Tg, class Tb >
25         TOutPixel operator()( const Tr& r, const Tg& g, const Tb& b ) const
26           {
27             TOutPixel rgb;
28             rgb[ 0 ] = O( r );
29             rgb[ 1 ] = O( g );
30             rgb[ 2 ] = O( b );
31             return( rgb );
32           }
33
34         template< class C >
35         TOutPixel operator()( const itk::RGBPixel< C >& rgb ) const
36           {
37             return(
38               this->operator()(
39                 rgb.GetRed( ), rgb.GetGreen( ), rgb.GetBlue( )
40                 )
41               );
42           }
43       };
44
45     } // ecapseman
46
47 } // ecapseman
48
49 #endif // __CPEXTENSIONS__ALGORITHMS__RGBTORGBFUNCTION__H__
50
51 // eof - $RCSfile$