TuttleOFX  1
bilinear.hpp
Go to the documentation of this file.
00001 #ifndef _TERRY_SAMPLER_BILINEAR_HPP_
00002 #define _TERRY_SAMPLER_BILINEAR_HPP_
00003 
00004 #include "details.hpp"
00005 
00006 namespace terry {
00007 using namespace boost::gil;
00008 namespace sampler {
00009 
00010 struct bilinear_sampler
00011 {
00012         const size_t _windowSize;
00013 
00014         bilinear_sampler() :
00015                 _windowSize ( 2.0 )
00016         {}
00017 
00018         /**
00019          * @brief Get weight for a specific distance, for all bilinear resampler.
00020          *
00021          * @param[in] distance between the pixels and the current pixel
00022          * @param[out] weight return value to weight the pixel in filtering
00023          */
00024         template<typename Weight>
00025         void operator()( const RESAMPLING_CORE_TYPE& distance, Weight& weight )
00026         {
00027                 RESAMPLING_CORE_TYPE absDistance = std::abs( (RESAMPLING_CORE_TYPE) distance );
00028                 if( absDistance < 1 )
00029                 {
00030                         weight = ( 1.0 - absDistance );
00031                 }
00032                 else
00033                 {
00034                         weight = 0;
00035                 }
00036         }
00037 };
00038 
00039 }
00040 }
00041 
00042 #endif
00043