GaussianFilter.cpp

Go to the documentation of this file.
00001 /**<!-------------------------------------------------------------------->
00002    @file   GaussianFilter.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 discrete, symmetric gaussian filter (separable like most of the 
00009    other filters, but we're not taking advantage of this to make the 
00010    filter framework cleaner and more cohesive), centered at the origin
00011    <!-------------------------------------------------------------------->**/
00012 
00013 #include "GaussianFilter.h"
00014 
00015 void GaussianFilter::init() {
00016    KernelFilter::init();
00017    
00018    m_sigma = getValue<real_t>("sigma", m_sigma);
00019 }
00020 
00021 real_t GaussianFilter::evaluate(const Vector2 &pt) {
00022    ASSERT(m_sigma > 0); // note assuming sigma positive when it suffices to 
00023                         // assume sigma is non-negative ; shouldn't matter
00024                         // but it prevents a special case for sigma at zero
00025    
00026    const real_t coeff  = (-0.5) / (m_sigma * m_sigma);
00027    const real_t weight = coeff * (pt[0] * pt[0] + pt[1] * pt[1]);
00028    
00029    return MAX(0, (1.0 / (sqrt(2.0 * M_PI) * m_sigma)) * exp(weight));
00030 }
00031 

Generated on 28 Feb 2009 for Milton by doxygen 1.5.6