X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpExtensions%2FAlgorithms%2FRGBToRGBFunction.h;fp=lib%2FcpExtensions%2FAlgorithms%2FRGBToRGBFunction.h;h=97b85ce14658f41a7f2f2ff51b43e7734f5d4c70;hb=2361f4f97631e09d88d8a5510a369817dcaa19db;hp=0000000000000000000000000000000000000000;hpb=e18f55af541dba9026284beb6f12ef06b12e6f47;p=cpPlugins.git diff --git a/lib/cpExtensions/Algorithms/RGBToRGBFunction.h b/lib/cpExtensions/Algorithms/RGBToRGBFunction.h new file mode 100644 index 0000000..97b85ce --- /dev/null +++ b/lib/cpExtensions/Algorithms/RGBToRGBFunction.h @@ -0,0 +1,51 @@ +// ------------------------------------------------------------------------- +// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co) +// ------------------------------------------------------------------------- + +#ifndef __CPEXTENSIONS__ALGORITHMS__RGBTORGBFUNCTION__H__ +#define __CPEXTENSIONS__ALGORITHMS__RGBTORGBFUNCTION__H__ + +#include +#include +#include + +namespace cpExtensions + { + namespace Algorithms + { + /** + */ + template< class O > + struct RGBToRGBFunction + { + typedef RGBToRGBFunction Self; + typedef itk::Vector< O, 3 > TOutPixel; + + template< class Tr, class Tg, class Tb > + TOutPixel operator()( const Tr& r, const Tg& g, const Tb& b ) const + { + TOutPixel rgb; + rgb[ 0 ] = O( r ); + rgb[ 1 ] = O( g ); + rgb[ 2 ] = O( b ); + return( rgb ); + } + + 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__RGBTORGBFUNCTION__H__ + +// eof - $RCSfile$