DKLcolorChannel.C

Go to the documentation of this file.
00001 /*!@file Channels/DKLcolorChannel.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/DKLcolorChannel.C $
00035 // $Id: DKLcolorChannel.C 12962 2010-03-06 02:13:53Z irock $
00036 //
00037 
00038 #include "Channels/DKLcolorChannel.H"
00039 
00040 #include "Channels/ChannelOpts.H"
00041 #include "Channels/DcolorChannel.H"
00042 #include "Channels/KcolorChannel.H"
00043 #include "Channels/LcolorChannel.H"
00044 #include "Component/ModelOptionDef.H"
00045 #include "Component/OptionManager.H"
00046 #include "Image/ColorOps.H"
00047 #include "rutz/trace.h"
00048 
00049 const ModelOptionDef OPT_DKLcolorChannelDweight =
00050   { MODOPT_ARG(float), "DKLcolorChannelDweight", &MOC_CHANNEL, OPTEXP_CORE,
00051     "Weight to assign to the D component of the DKL color channel",
00052     "dkl-d-weight", '\0', "<float>", "1.0" };
00053 
00054 const ModelOptionDef OPT_DKLcolorChannelKweight =
00055   { MODOPT_ARG(float), "DKLcolorChannelKweight", &MOC_CHANNEL, OPTEXP_CORE,
00056     "Weight to assign to the K component of the DKL color channel",
00057     "dkl-k-weight", '\0', "<float>", "1.0" };
00058 
00059 const ModelOptionDef OPT_DKLcolorChannelLweight =
00060   { MODOPT_ARG(float), "DKLcolorChannelLweight", &MOC_CHANNEL, OPTEXP_CORE,
00061     "Weight to assign to the L component of the DKL color channel",
00062     "dkl-l-weight", '\0', "<float>", "1.0" };
00063 
00064 // ######################################################################
00065 // DKLcolorChannel member definitions:
00066 // ######################################################################
00067 
00068 DKLcolorChannel::DKLcolorChannel(OptionManager& mgr) :
00069   ComplexChannel(mgr, "DKLcolor", "DKLcolor", DKLCOLOR),
00070   itsDweight(&OPT_DKLcolorChannelDweight, this),
00071   itsKweight(&OPT_DKLcolorChannelKweight, this),
00072   itsLweight(&OPT_DKLcolorChannelLweight, this),
00073   itsD(new DcolorChannel(getManager(), true)),
00074   itsK(new KcolorChannel(getManager(), true)),
00075   itsL(new LcolorChannel(getManager(), true))
00076 {
00077 GVX_TRACE(__PRETTY_FUNCTION__);
00078 
00079   this->addSubChan(itsD);
00080   this->addSubChan(itsK);
00081   this->addSubChan(itsL);
00082 }
00083 
00084 // ######################################################################
00085 DcolorChannel& DKLcolorChannel::Dcolor() const
00086 {
00087 GVX_TRACE(__PRETTY_FUNCTION__);
00088   return *itsD;
00089 }
00090 
00091 // ######################################################################
00092 KcolorChannel& DKLcolorChannel::Kcolor() const
00093 {
00094 GVX_TRACE(__PRETTY_FUNCTION__);
00095   return *itsK;
00096 }
00097 
00098 // ######################################################################
00099 LcolorChannel& DKLcolorChannel::Lcolor() const
00100 {
00101 GVX_TRACE(__PRETTY_FUNCTION__);
00102   return *itsL;
00103 }
00104 
00105 // ######################################################################
00106 DKLcolorChannel::~DKLcolorChannel()
00107 {
00108 GVX_TRACE(__PRETTY_FUNCTION__);
00109 }
00110 
00111 // ######################################################################
00112 void DKLcolorChannel::start1()
00113 {
00114   LINFO("Using a weight of %f for D subchannel", itsDweight.getVal());
00115   setSubchanTotalWeight(*itsD, itsDweight.getVal());
00116 
00117   LINFO("Using a weight of %f for K subchannel", itsKweight.getVal());
00118   setSubchanTotalWeight(*itsK, itsKweight.getVal());
00119 
00120   LINFO("Using a weight of %f for L subchannel", itsLweight.getVal());
00121   setSubchanTotalWeight(*itsL, itsLweight.getVal());
00122 }
00123 
00124 // ######################################################################
00125 void DKLcolorChannel::doInput(const InputFrame& inframe)
00126 {
00127 GVX_TRACE(__PRETTY_FUNCTION__);
00128   Image<float> dimg, kimg, limg;
00129 
00130   // get the D, K, L components, as signed floats:
00131   LINFO("Converting input image to DKL colors.");
00132   getDKL(inframe.colorByte(), dimg, kimg, limg);
00133 
00134   // feed our subchannels:
00135   itsD->input(InputFrame::fromGrayFloat(&dimg, inframe.time(), &inframe.clipMask(), inframe.pyrCache()));
00136   itsK->input(InputFrame::fromGrayFloat(&kimg, inframe.time(), &inframe.clipMask(), inframe.pyrCache()));
00137   itsL->input(InputFrame::fromGrayFloat(&limg, inframe.time(), &inframe.clipMask(), inframe.pyrCache()));
00138   LINFO("DKL Color channel ok.");
00139 }
00140 
00141 // ######################################################################
00142 /* So things look consistent in everyone's emacs... */
00143 /* Local Variables: */
00144 /* indent-tabs-mode: nil */
00145 /* End: */
Generated on Sun May 8 08:40:21 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3