FeatureBiaser.C

Go to the documentation of this file.
00001 /*!@file Channels/FeatureBiaser.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/FeatureBiaser.C $
00035 // $Id: FeatureBiaser.C 9720 2008-04-30 07:32:00Z itti $
00036 //
00037 
00038 #ifndef CHANNELS_FEATUREBIASER_C_DEFINED
00039 #define CHANNELS_FEATUREBIASER_C_DEFINED
00040 
00041 #include "Channels/FeatureBiaser.H"
00042 
00043 #include "Channels/ComplexChannel.H"
00044 #include "Channels/SingleChannel.H"
00045 
00046 // ######################################################################
00047 FeatureBiaser::FeatureBiaser(const double* mean, const double* sigma)
00048   :
00049   itsMean(mean),
00050   itsSigma(sigma),
00051   itsIndex(0)
00052 {}
00053 
00054 // ######################################################################
00055 FeatureBiaser::~FeatureBiaser() {}
00056 
00057 // ######################################################################
00058 void FeatureBiaser::visitChannelBase(ChannelBase& chan)
00059 {
00060   LFATAL("don't know how to handle %s", chan.tagName().c_str());
00061 }
00062 
00063 // ######################################################################
00064 void FeatureBiaser::visitSingleChannel(SingleChannel& chan)
00065 {
00066   chan.killCaches();
00067   const uint num = chan.numSubmaps();
00068   for (uint i = 0; i < num; ++i)
00069     {
00070       const uint subidx = itsIndex % num;
00071       ASSERT( chan.getLevelSpec().indexOK(subidx) );
00072 
00073 
00074       LFATAL("FIXME");
00075       ///////      chan.setMean(subidx, this->itsMean[itsIndex]);
00076       //////// chan.setSigma(subidx, this->itsSigma[itsIndex]);
00077       ++itsIndex;
00078     }
00079 }
00080 
00081 // ######################################################################
00082 void FeatureBiaser::visitComplexChannel(ComplexChannel& chan)
00083 {
00084   for (uint i = 0; i < chan.numChans(); ++i)
00085     chan.subChan(i)->accept(*this);
00086 }
00087 
00088 
00089 // ######################################################################
00090 WeightFinder::WeightFinder() : itsMax()
00091 {
00092   itsMax.push_back(0.0);
00093 }
00094 
00095 // ######################################################################
00096 WeightFinder::~WeightFinder() {}
00097 
00098 // ######################################################################
00099 void WeightFinder::visitChannelBase(ChannelBase& chan)
00100 {
00101   LFATAL("don't know how to handle %s", chan.tagName().c_str());
00102 }
00103 
00104 // ######################################################################
00105 void WeightFinder::visitSingleChannel(SingleChannel& chan)
00106 {
00107   chan.killCaches();
00108 
00109   // first clamp our coefficients to [0,255]
00110       LFATAL("FIXME");
00111       //////  chan.clampCoeffs(0.0, 255.0);
00112 
00113   double sum = 0.0;
00114   // initialise the submap weights
00115   for (uint idx = 0; idx < chan.numSubmaps(); ++idx)
00116     {
00117       LFATAL("FIXME");
00118       double wt = 0.0;/////chan.getMean(idx) / (1.0 + chan.getSigma(idx));
00119       sum += wt;
00120       itsMax.back() = std::max(itsMax.back(), wt);
00121     }
00122 
00123   // normalize submap weights so that they add to 1
00124   for (uint idx = 0; idx < chan.numSubmaps(); ++idx)
00125     {
00126       LFATAL("FIXME");
00127       ////double wt = chan.getMean(idx) / (1.0 + chan.getSigma(idx));
00128       ////if (sum != 0.0) chan.setCoeff(idx, wt/sum);
00129     }
00130 }
00131 
00132 // ######################################################################
00133 void WeightFinder::visitComplexChannel(ComplexChannel& chan)
00134 {
00135   double sum = 0.0;
00136   for (uint i = 0; i < chan.numChans(); ++i)
00137     {
00138       // first find the subchannel's weights
00139       itsMax.push_back(0.0);
00140       chan.subChan(i)->accept(*this);
00141       const double wt = itsMax.back();
00142       itsMax.pop_back();
00143 
00144       // initialize channel's weight with the max submap/subchan weight
00145       chan.setSubchanTotalWeight(i, wt);
00146 
00147       itsMax.back() = std::max(itsMax.back(), wt);
00148       sum += wt;
00149     }
00150 
00151   // normalize subchannel weights so that they add to 1
00152   for (uint i = 0; i < chan.numChans(); ++i)
00153     {
00154       if (sum != 0.0)
00155         chan.setSubchanTotalWeight
00156           (i, chan.getSubchanTotalWeight(i)/sum);
00157     }
00158 }
00159 
00160 // ######################################################################
00161 /* So things look consistent in everyone's emacs... */
00162 /* Local Variables: */
00163 /* mode: c++ */
00164 /* indent-tabs-mode: nil */
00165 /* End: */
00166 
00167 #endif // CHANNELS_FEATUREBIASER_C_DEFINED
Generated on Sun May 8 08:40:21 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3