X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpExtensions%2FAlgorithms%2FRGBExtractFunction.h;h=ec7126b12ed720e986f30faf47f7cc0dbbb2fb4c;hb=0bb74f9a32de4ce1559973ebf72fda495aa2c587;hp=8db169720ee77e49f5c3826e4a937235c4bef34d;hpb=2361f4f97631e09d88d8a5510a369817dcaa19db;p=cpPlugins.git diff --git a/lib/cpExtensions/Algorithms/RGBExtractFunction.h b/lib/cpExtensions/Algorithms/RGBExtractFunction.h index 8db1697..ec7126b 100644 --- a/lib/cpExtensions/Algorithms/RGBExtractFunction.h +++ b/lib/cpExtensions/Algorithms/RGBExtractFunction.h @@ -10,42 +10,42 @@ #include #include -#include namespace cpExtensions +{ + namespace Algorithms { - namespace Algorithms + /** + */ + template< class P > + struct RGBExtractFunction { - /** - */ - template< class O > - struct RGBExtractFunction - { - typedef RGBExtractFunction 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 + 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