FlickerChannel.C

Go to the documentation of this file.
00001 /*!@file Channels/FlickerChannel.C */
00002 
00003 // //////////////////////////////////////////////////////////////////// //
00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2005   //
00005 // by the University of Southern California (USC) and the iLab at USC.  //
00006 // See http://iLab.usc.edu for information about this project.          //
00007 // //////////////////////////////////////////////////////////////////// //
00008 // Major portions of the iLab Neuromorphic Vision Toolkit are protected //
00009 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency //
00010 // in Visual Environments, and Applications'' by Christof Koch and      //
00011 // Laurent Itti, California Institute of Technology, 2001 (patent       //
00012 // pending; application number 09/912,225 filed July 23, 2001; see      //
00013 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status).     //
00014 // //////////////////////////////////////////////////////////////////// //
00015 // This file is part of the iLab Neuromorphic Vision C++ Toolkit.       //
00016 //                                                                      //
00017 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can   //
00018 // redistribute it and/or modify it under the terms of the GNU General  //
00019 // Public License as published by the Free Software Foundation; either  //
00020 // version 2 of the License, or (at your option) any later version.     //
00021 //                                                                      //
00022 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope  //
00023 // that it will be useful, but WITHOUT ANY WARRANTY; without even the   //
00024 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
00025 // PURPOSE.  See the GNU General Public License for more details.       //
00026 //                                                                      //
00027 // You should have received a copy of the GNU General Public License    //
00028 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write   //
00029 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,   //
00030 // Boston, MA 02111-1307 USA.                                           //
00031 // //////////////////////////////////////////////////////////////////// //
00032 //
00033 // Primary maintainer for this file:
00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Channels/FlickerChannel.C $
00035 // $Id: FlickerChannel.C 14477 2011-02-04 22:52:28Z dberg $
00036 //
00037 
00038 #ifndef FLICKERCHANNEL_C_DEFINED
00039 #define FLICKERCHANNEL_C_DEFINED
00040 
00041 #include "Channels/FlickerChannel.H"
00042 
00043 #include "Image/MathOps.H" // for absDiff()
00044 #include "rutz/trace.h"
00045 
00046 // ######################################################################
00047 // FlickerChannel member definitions:
00048 // ######################################################################
00049 
00050 // ######################################################################
00051 FlickerChannel::FlickerChannel(OptionManager& mgr, const std::string& descrNam, const std::string& tagNam) :
00052   GaussianPyrChannel(mgr, descrNam, tagNam, FLICKER),
00053   itsTimeConst("FlickerChannelTimeConst", this, SimTime::SECS(0.03)),
00054   itsPrevInput(),
00055   itsPrevTime(SimTime::ZERO())
00056 {
00057 GVX_TRACE(__PRETTY_FUNCTION__);
00058   itsTakeAbs.setVal(true);
00059   itsNormalizeOutput.setVal(true);
00060 }
00061 
00062 // ######################################################################
00063 FlickerChannel::~FlickerChannel()
00064 {
00065 GVX_TRACE(__PRETTY_FUNCTION__);
00066 }
00067 
00068 // ######################################################################
00069 void FlickerChannel::doInput(const InputFrame& inframe)
00070 {
00071 GVX_TRACE(__PRETTY_FUNCTION__);
00072   ASSERT(inframe.grayFloat().initialized());
00073 
00074   // If this is the first time the flicker channel has seen input,
00075   // then itsPrevInput will be uninitialized; obviously we can't
00076   // compute any flicker with only one frame, so we just store the
00077   // current input as the next iteration's previous input
00078   if (!itsPrevInput.initialized())
00079     {
00080       itsPrevInput = inframe.grayFloat();
00081       itsPrevTime = inframe.time();
00082     }
00083   else
00084     {
00085       // take simple abs difference between current and previous frame:
00086       Image<float> fli = absDiff(inframe.grayFloat(), itsPrevInput);
00087 
00088       SingleChannel::doInput(InputFrame::fromGrayFloat
00089                              (&fli, inframe.time(),
00090                               &inframe.clipMask(), inframe.pyrCache()));
00091 
00092       // update the previous image:
00093       if (inframe.time() - itsPrevTime >= itsTimeConst.getVal())
00094         {
00095           itsPrevInput = inframe.grayFloat();
00096           itsPrevTime = inframe.time();
00097         }
00098       else
00099         {
00100           const float fac =
00101             float( (inframe.time() - itsPrevTime).secs() / itsTimeConst.getVal().secs() );
00102           itsPrevInput = itsPrevInput * (1.0F - fac) + inframe.grayFloat() * fac;
00103           itsPrevTime = inframe.time();
00104         }
00105     }
00106 }
00107 
00108 // ######################################################################
00109 void FlickerChannel::reset1()
00110 {
00111 GVX_TRACE(__PRETTY_FUNCTION__);
00112   // reset some stuff in FlickerChannel
00113   itsPrevInput.freeMem();
00114 
00115   // propagate to our base class:
00116   SingleChannel::reset1();
00117 }
00118 
00119 // ######################################################################
00120 /* So things look consistent in everyone's emacs... */
00121 /* Local Variables: */
00122 /* indent-tabs-mode: nil */
00123 /* End: */
00124 
00125 #endif // FLICKERCHANNEL_C_DEFINED
Generated on Sun May 8 08:04:35 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3