TuttleOFX
1
|
00001 #ifndef _TERRY_ALGORITHM_PIXEL_BY_CHANNEL_HPP_ 00002 #define _TERRY_ALGORITHM_PIXEL_BY_CHANNEL_HPP_ 00003 00004 #include <boost/gil/gil_config.hpp> 00005 #include <boost/gil/pixel.hpp> 00006 #include <boost/gil/color_base_algorithm.hpp> 00007 00008 namespace terry { 00009 namespace algorithm { 00010 00011 using namespace boost::gil; 00012 00013 /** 00014 * @brief Allows to use a per channel fonctor. 00015 */ 00016 template<template<class> class Func> 00017 struct transform_pixel_by_channel_t 00018 { 00019 template<typename Pixel> 00020 GIL_FORCEINLINE 00021 Pixel operator()( const Pixel& a ) const 00022 { 00023 Pixel result; 00024 static_for_each( 00025 a, 00026 result, 00027 Func<typename channel_type<Pixel>::type>() 00028 ); 00029 return result; 00030 } 00031 template<typename Pixel> 00032 GIL_FORCEINLINE 00033 Pixel operator()( const Pixel& a, const Pixel& b ) const 00034 { 00035 Pixel result; 00036 static_for_each( 00037 a, 00038 b, 00039 result, 00040 Func<typename channel_type<Pixel>::type>() 00041 ); 00042 return result; 00043 } 00044 template<typename Pixel> 00045 GIL_FORCEINLINE 00046 Pixel operator()( const Pixel& a, const Pixel& b, const Pixel& c ) const 00047 { 00048 Pixel result; 00049 static_for_each( 00050 a, 00051 b, 00052 c, 00053 result, 00054 Func<typename channel_type<Pixel>::type>() 00055 ); 00056 return result; 00057 } 00058 template<typename Pixel> 00059 GIL_FORCEINLINE 00060 Pixel operator()( const Pixel& a, const Pixel& b, const Pixel& c, const Pixel& d ) const 00061 { 00062 Pixel result; 00063 static_for_each( 00064 a, 00065 b, 00066 c, 00067 d, 00068 result, 00069 Func<typename channel_type<Pixel>::type>() 00070 ); 00071 return result; 00072 } 00073 }; 00074 00075 00076 } 00077 } 00078 00079 #endif 00080