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