TuttleOFX
1
|
00001 #ifndef HSL_ALGORITHMS_HPP 00002 #define HSL_ALGORITHMS_HPP 00003 00004 #include <boost/gil/gil_all.hpp> 00005 00006 namespace boost { namespace gil { 00007 namespace toolbox { 00008 00009 template< typename HSL_VIEW > 00010 void shift_hue( const HSL_VIEW& img 00011 , const bits32f value ) 00012 { 00013 // make sure src and dst are views 00014 // make sure src and dst are either hsl or hsv 00015 00016 for( int y = 0; y < img.height(); ++y ) 00017 { 00018 HSL_VIEW::x_iterator img_it = img.row_begin( y ); 00019 00020 for( int x = 0; x < img.width(); ++x ) 00021 { 00022 bits32f& hue = get_color( img_it[x], boost::gil::hsl_color_space::hue_t() ); 00023 00024 hue += value; 00025 00026 if( hue > 1.f ) 00027 { 00028 hue -= 1.f; 00029 } 00030 00031 if( hue < 0.f ) 00032 { 00033 hue = 0.f; 00034 } 00035 } 00036 } 00037 } 00038 00039 00040 } //namespace toolbox 00041 } //namespace gil 00042 } //namespace boost 00043 00044 #endif // HSL_ALGORITHMS_HPP