MSTChannel.C

Go to the documentation of this file.
00001 /*!@file Channels/MSTChannel.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/MSTChannel.C $
00035 // $Id: MSTChannel.C 14356 2011-01-04 21:30:52Z dberg $
00036 //
00037 
00038 #ifndef MSTCHANNEL_C_DEFINED
00039 #define MSTCHANNEL_C_DEFINED
00040 
00041 #include "Channels/MSTChannel.H"
00042 
00043 #include "Channels/ChannelOpts.H"
00044 #include "Channels/ComplexChannel.H"
00045 #include "Channels/DirectionChannel.H"
00046 #include "Channels/MotionChannel.H"
00047 #include "Component/OptionManager.H"
00048 #include "Image/FilterOps.H"
00049 #include "Util/sformat.H"
00050 #include "rutz/trace.h"
00051 
00052 // ######################################################################
00053 // MST Channel member definitions:
00054 // ######################################################################
00055 MSTChannel::MSTChannel(OptionManager& mgr,
00056                                  nub::soft_ref<MotionChannel> oc,
00057                                  const VisualFeature vs,
00058                                  const int r0, const int r1, const int r2,
00059                                  const int r3, const int r4, const int r5,
00060                                  const int r6, const int r7) :
00061   SingleChannel(mgr, "MSTChannel", "MSTChannel", vs,
00062                 rutz::shared_ptr< PyrBuilder<float> >(NULL)),
00063   itsFull(vs == FOEMST ? &OPT_EFullImplementation :
00064           (ModelOptionDef*) 0,
00065           this),  // see Channels/ChannelOpts.C
00066   itsDelta(vs == FOEMST ? &OPT_EndPointChannelDelta :
00067            (ModelOptionDef*) 0,
00068            this),
00069   itsOriChan(oc),
00070   R0(r0), R1(r1), R2(r2), R3(r3), R4(r4), R5(r5), R6(r6), R7(r7)
00071 {
00072 GVX_TRACE(__PRETTY_FUNCTION__);
00073   itsTakeAbs.setVal(true);
00074  
00075   setDescriptiveName(sformat("MST(%d%d%d%d%d%d%d%d)",
00076                              r0, r1, r2, r3, r4, r5, r6, r7));
00077 
00078   setTagName(sformat("MST_%d%d%d%d%d%d%d%d",
00079                      r0, r1, r2, r3, r4, r5, r6, r7));
00080 LINFO("***mst**");
00081 }
00082 
00083 // ######################################################################
00084 MSTChannel::~MSTChannel()
00085 {
00086 GVX_TRACE(__PRETTY_FUNCTION__);
00087 }
00088 
00089 // ######################################################################
00090 void MSTChannel::doInput(const InputFrame& inframe)
00091 {
00092 GVX_TRACE(__PRETTY_FUNCTION__);
00093   // access the orientation channel
00094   ASSERT(itsOriChan.get() != 0);
00095   const uint num = itsOriChan->getModelParamVal<uint>("NumDirections");
00096   ASSERT(num == 4);
00097 
00098   LINFO("**doing input in *mst**");
00099   
00100   // access the gabor pyramids at the relevant orientations: 0, 45,
00101   // 90, 135
00102   const ImageSet<float>& ori0_pyr =
00103     dynCast<SingleChannel>(itsOriChan->subChan(0))->pyramid(0);
00104   const ImageSet<float>& ori45_pyr =
00105     dynCast<SingleChannel>(itsOriChan->subChan(1))->pyramid(0);
00106   const ImageSet<float>& ori90_pyr =
00107     dynCast<SingleChannel>(itsOriChan->subChan(2))->pyramid(0);
00108   const ImageSet<float>& ori135_pyr =
00109     dynCast<SingleChannel>(itsOriChan->subChan(3))->pyramid(0);
00110 
00111   ImageSet<float> result(ori0_pyr.size());
00112   SingleChannel::killCaches();
00113   SingleChannel::setClipPyramid(inframe.clipMask());
00114 
00115   const bool R[8] = { (bool)R0, (bool)R1, (bool)R2, (bool)R3, (bool)R4, 
00116                       (bool)R5, (bool)R6, (bool)R7 };
00117 
00118   const uint dx = itsDelta.getVal();
00119   const uint dy = itsDelta.getVal();
00120 
00121   //LINFO("MST Delta %d",itsDelta.getVal());
00122 
00123   // combine the orientation pyramids to form the L pyramid
00124 
00125 
00126   if (itsFull.getVal())
00127   {
00128 
00129     for (uint i = 0; i < ori0_pyr.size(); i ++)
00130       result[i] = MSTFilterFull(ori0_pyr[i],  ori45_pyr[i],
00131                                 ori90_pyr[i], ori135_pyr[i],
00132                                 R, dx, dy);
00133   }
00134   else
00135   {
00136     for (uint i = 0; i < ori0_pyr.size(); i ++)
00137       result[i] = MSTFilterPartial(ori0_pyr[i],  ori45_pyr[i],
00138                                    ori90_pyr[i], ori135_pyr[i],
00139                                    R, dx, dy);
00140   }
00141    // store the result
00142    SingleChannel::storePyramid(result, inframe.time());
00143 }
00144 
00145 // ######################################################################
00146 /* So things look consistent in everyone's emacs... */
00147 /* Local Variables: */
00148 /* indent-tabs-mode: nil */
00149 /* End: */
00150 
00151 #endif // MSTCHANNEL_C_DEFINED
Generated on Sun May 8 08:40:22 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3