LanczosSincFilter.cpp
Go to the documentation of this file.00001 /**<!--------------------------------------------------------------------> 00002 @file LanczosSincFilter.cpp 00003 @author Travis Fischer (fisch0920@gmail.com) 00004 @author Matthew Jacobs (jacobs.mh@gmail.com) 00005 @date Fall 2008 00006 00007 @brief 00008 2D symmetric Lanczos filter whose aim is to approximate a truncated 00009 sinc (the ideal reconstruction filter) while minimizing the amount of 00010 visible ringing resulting from the truncation 00011 00012 @note 00013 LanczosSinc Filter taken from PBRT (Pharr, Humphreys) 00014 http://www.pbrt.org 00015 <!-------------------------------------------------------------------->**/ 00016 00017 #include "LanczosSincFilter.h" 00018 00019 void LanczosSincFilter::init() { 00020 KernelFilter::init(); 00021 00022 m_tau = getValue<real_t>("tau", m_tau); 00023 } 00024 00025 real_t LanczosSincFilter::evaluate(const Vector2 &pt) { 00026 return _evaluate(pt[0]) * _evaluate(pt[1]); 00027 } 00028 00029 real_t LanczosSincFilter::_evaluate(real_t x) const { 00030 x = fabs(x / m_support); 00031 00032 if (x < EPSILON) 00033 return 1; 00034 00035 if (x > 1) 00036 return 0; 00037 00038 x *= M_PI; 00039 00040 const real_t sinc = sin(x * m_tau) / (x * m_tau); 00041 const real_t lanczos = sin(x) / x; 00042 00043 return sinc * lanczos; 00044 } 00045
Generated on 28 Feb 2009 for Milton by
1.5.6