SOColorChannel.C

Go to the documentation of this file.
00001 /*!@file Channels/SOColorChannel.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/SOColorChannel.C $
00035 // $Id: SOColorChannel.C 8195 2007-03-30 04:34:07Z rjpeters $
00036 //
00037 
00038 #ifndef SOCOLORCHANNEL_C_DEFINED
00039 #define SOCOLORCHANNEL_C_DEFINED
00040 
00041 #include "Channels/SOColorChannel.H"
00042 
00043 #include "Channels/BlueChannel.H"
00044 #include "Channels/GreenChannel.H"
00045 #include "Channels/RedChannel.H"
00046 #include "Channels/SOBlueYellowChannel.H"
00047 #include "Channels/SOGreenRedChannel.H"
00048 #include "Channels/SORedGreenChannel.H"
00049 #include "Channels/SOYellowBlueChannel.H"
00050 #include "Channels/YellowChannel.H"
00051 #include "Image/ColorOps.H"
00052 #include "rutz/trace.h"
00053 
00054 // ######################################################################
00055 // Single Opponent ColorChannel member definitions:
00056 // ######################################################################
00057 SOColorChannel::SOColorChannel(OptionManager& mgr) :
00058   ComplexChannel(mgr, "SOColor", "single-opponent-color", SOCOLOR),
00059   itsLumThresh("ColorChannelLuminanceThreshold", this, 25.5F),
00060   itsRG(makeSharedComp(new SORedGreenChannel(mgr))),
00061   itsGR(makeSharedComp(new SOGreenRedChannel(mgr))),
00062   itsBY(makeSharedComp(new SOBlueYellowChannel(mgr))),
00063   itsYB(makeSharedComp(new SOYellowBlueChannel(mgr))),
00064   itsR(makeSharedComp(new RedChannel(mgr))),
00065   itsG(makeSharedComp(new GreenChannel(mgr))),
00066   itsB(makeSharedComp(new BlueChannel(mgr))),
00067   itsY(makeSharedComp(new YellowChannel(mgr)))
00068 {
00069 GVX_TRACE(__PRETTY_FUNCTION__);
00070   this->addSubChan(itsRG);
00071   this->addSubChan(itsGR);
00072   this->addSubChan(itsBY);
00073   this->addSubChan(itsYB);
00074 
00075   // the following channels are computed to obtain the pyramids for
00076   // the above channels
00077   this->addSubChan(itsR);
00078   this->addSubChan(itsG);
00079   this->addSubChan(itsB);
00080   this->addSubChan(itsY);
00081 
00082   // these pure color channels are not considered for saliency
00083   this->setSubchanTotalWeight(*itsR, 0.0);
00084   this->setSubchanTotalWeight(*itsG, 0.0);
00085   this->setSubchanTotalWeight(*itsB, 0.0);
00086   this->setSubchanTotalWeight(*itsY, 0.0);
00087 }
00088 
00089 // ######################################################################
00090 SORedGreenChannel&   SOColorChannel::rg() const { return *itsRG; }
00091 SOGreenRedChannel&   SOColorChannel::gr() const { return *itsGR; }
00092 SOBlueYellowChannel& SOColorChannel::by() const { return *itsBY; }
00093 SOYellowBlueChannel& SOColorChannel::yb() const { return *itsYB; }
00094 RedChannel&          SOColorChannel::r()  const { return *itsR; }
00095 GreenChannel&        SOColorChannel::g()  const { return *itsG; }
00096 BlueChannel&         SOColorChannel::b()  const { return *itsB; }
00097 YellowChannel&       SOColorChannel::y()  const { return *itsY; }
00098 
00099 // ######################################################################
00100 SOColorChannel::~SOColorChannel()
00101 {
00102 GVX_TRACE(__PRETTY_FUNCTION__);
00103 }
00104 
00105 // ######################################################################
00106 void SOColorChannel::doInput(const InputFrame& inframe)
00107 {
00108 GVX_TRACE(__PRETTY_FUNCTION__);
00109   ASSERT(inframe.colorFloat().initialized());
00110 
00111   Image<float> red, green, blue, yellow;
00112   getRGBY(inframe.colorFloat(), red, green, blue, yellow,
00113           itsLumThresh.getVal());
00114   // first find the pyramids for each color
00115   itsR->input(InputFrame::fromGrayFloat
00116               (&red, inframe.time(), &inframe.clipMask(), inframe.pyrCache()));
00117   itsG->input(InputFrame::fromGrayFloat
00118               (&green, inframe.time(), &inframe.clipMask(), inframe.pyrCache()));
00119   itsB->input(InputFrame::fromGrayFloat
00120               (&blue, inframe.time(), &inframe.clipMask(), inframe.pyrCache()));
00121   itsY->input(InputFrame::fromGrayFloat
00122               (&yellow, inframe.time(), &inframe.clipMask(), inframe.pyrCache()));
00123 
00124   const Dims d = inframe.getDims();
00125 
00126   // then compute the single opponent center-surround using the above
00127   // pyramids
00128   rg().singleOpponentInput(d, r().pyramid(0), g().pyramid(0),
00129                            inframe.time(), inframe.clipMask());
00130   gr().singleOpponentInput(d, g().pyramid(0), r().pyramid(0),
00131                            inframe.time(), inframe.clipMask());
00132   by().singleOpponentInput(d, b().pyramid(0), y().pyramid(0),
00133                            inframe.time(), inframe.clipMask());
00134   yb().singleOpponentInput(d, y().pyramid(0), b().pyramid(0),
00135                            inframe.time(), inframe.clipMask());
00136   LINFO("Single Opponent Color channel ok.");
00137 }
00138 
00139 // ######################################################################
00140 void SOColorChannel::setRG(nub::ref<SORedGreenChannel> RG)
00141 { this->removeSubChan(itsRG); itsRG = RG; this->addSubChan(itsRG); }
00142 
00143 void SOColorChannel::setGR(nub::ref<SOGreenRedChannel> GR)
00144 { this->removeSubChan(itsGR); itsGR = GR; this->addSubChan(itsGR); }
00145 
00146 void SOColorChannel::setBY(nub::ref<SOBlueYellowChannel> BY)
00147 { this->removeSubChan(itsBY); itsBY = BY; this->addSubChan(itsBY); }
00148 
00149 void SOColorChannel::setYB(nub::ref<SOYellowBlueChannel> YB)
00150 { this->removeSubChan(itsYB); itsYB = YB; this->addSubChan(itsYB); }
00151 
00152 void SOColorChannel::setR(nub::ref<RedChannel> R)
00153 { this->removeSubChan(itsR); itsR = R; this->addSubChan(itsR); }
00154 
00155 void SOColorChannel::setG(nub::ref<GreenChannel> G)
00156 { this->removeSubChan(itsG); itsG = G; this->addSubChan(itsG); }
00157 
00158 void SOColorChannel::setB(nub::ref<BlueChannel> B)
00159 { this->removeSubChan(itsB); itsB = B; this->addSubChan(itsB); }
00160 
00161 void SOColorChannel::setY(nub::ref<YellowChannel> Y)
00162 { this->removeSubChan(itsY); itsY = Y; this->addSubChan(itsY); }
00163 
00164 
00165 // ######################################################################
00166 /* So things look consistent in everyone's emacs... */
00167 /* Local Variables: */
00168 /* indent-tabs-mode: nil */
00169 /* End: */
00170 
00171 #endif // SOCOLORCHANNEL_C_DEFINED
Generated on Sun May 8 08:40:22 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3