X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpExtensions%2FAlgorithms%2FRGBExtractFunction.h;fp=lib%2FcpExtensions%2FAlgorithms%2FRGBExtractFunction.h;h=ec7126b12ed720e986f30faf47f7cc0dbbb2fb4c;hb=201c5026430f9bcc33f9db6a39f5d03db096c860;hp=0000000000000000000000000000000000000000;hpb=aa77db36cc1d87ba014c982a235239c3c87224f3;p=cpPlugins.git diff --git a/lib/cpExtensions/Algorithms/RGBExtractFunction.h b/lib/cpExtensions/Algorithms/RGBExtractFunction.h new file mode 100644 index 0000000..ec7126b --- /dev/null +++ b/lib/cpExtensions/Algorithms/RGBExtractFunction.h @@ -0,0 +1,54 @@ +// ------------------------------------------------------------------------- +// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co) +// ------------------------------------------------------------------------- + +#ifndef __CPEXTENSIONS__ALGORITHMS__RGBEXTRACTFUNCTION__H__ +#define __CPEXTENSIONS__ALGORITHMS__RGBEXTRACTFUNCTION__H__ + +#include +#include +#include + +#include + +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$