+// -------------------------------------------------------------------------
+// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
+// -------------------------------------------------------------------------
+
+#ifndef __CPEXTENSIONS__ALGORITHMS__RGBEXTRACTFUNCTION__H__
+#define __CPEXTENSIONS__ALGORITHMS__RGBEXTRACTFUNCTION__H__
+
+#include <cmath>
+#include <limits>
+#include <vnl/vnl_math.h>
+
+#include <itkRGBPixel.h>
+
+namespace cpExtensions
+{
+ namespace Algorithms
+ {
+ /**
+ */
+ template< class P >
+ struct RGBExtractFunction
+ {
+ typedef RGBExtractFunction Self;
+ typedef P TOutPixel;
+ typedef typename P::ValueType TValue;
+
+ template< class Tr, class Tg, class Tb >
+ P operator()( const Tr& r, const Tg& g, const Tb& b ) const
+ {
+ P out;
+ out[ 0 ] = TValue( r );
+ out[ 1 ] = TValue( g );
+ out[ 2 ] = TValue( b );
+ return( out );
+ }
+
+ template< class C >
+ TOutPixel operator()( const itk::RGBPixel< C >& rgb ) const
+ {
+ return(
+ this->operator()(
+ rgb.GetRed( ), rgb.GetGreen( ), rgb.GetBlue( )
+ )
+ );
+ }
+ };
+
+ } // ecapseman
+
+} // ecapseman
+
+#endif // __CPEXTENSIONS__ALGORITHMS__RGBEXTRACTFUNCTION__H__
+
+// eof - $RCSfile$