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