JunctionChannel.C

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