TuttleOFX  1
norm.hpp
Go to the documentation of this file.
00001 #ifndef _TERRY_COLOR_NORM_HPP_
00002 #define _TERRY_COLOR_NORM_HPP_
00003 
00004 #include <boost/math/special_functions/pow.hpp>
00005 
00006 namespace terry {
00007 namespace color {
00008 
00009 /**
00010  * @brief Compute the norm from the (x, y) coordinates of the input vector.
00011  */
00012 template<typename Channel>
00013 struct channel_norm_t
00014 {
00015         GIL_FORCEINLINE
00016         void operator()( const Channel& a, const Channel& b, Channel& res ) const
00017         {
00018                 res = std::sqrt( boost::math::pow<2>(a) + boost::math::pow<2>(b) );
00019         }
00020 };
00021 
00022 /**
00023  * @brief Compute the Manhattan norm from the (x, y) coordinates of the input vector.
00024  */
00025 template<typename Channel>
00026 struct channel_normManhattan_t
00027 {
00028         GIL_FORCEINLINE
00029         void operator()( const Channel& a, const Channel& b, Channel& res ) const
00030         {
00031                 res = std::abs(a) + std::abs(b);
00032         }
00033 };
00034 
00035 
00036 }
00037 }
00038 
00039 #endif