ImagizeColorChannel.C

Go to the documentation of this file.
00001 /*!@file Channels/ImagizeColorChannel.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/ImagizeColorChannel.C $
00035 // $Id: ImagizeColorChannel.C 12962 2010-03-06 02:13:53Z irock $
00036 //
00037 
00038 #include "Channels/ImagizeColorChannel.H"
00039 
00040 #include "Channels/ChannelOpts.H"
00041 #include "Channels/ImagizeAlphaChannel.H"
00042 #include "Channels/ImagizeBetaChannel.H"
00043 #include "Channels/ImagizeLedChannel.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_ImagizeColorChannelAweight =
00050   { MODOPT_ARG(float), "ImagizeColorChannelAweight", &MOC_CHANNEL, OPTEXP_CORE,
00051     "Weight to assign to the Alpha component of the Imagize color channel",
00052     "imgz-a-weight", '\0', "<float>", "1.0" };
00053 
00054 const ModelOptionDef OPT_ImagizeColorChannelBweight =
00055   { MODOPT_ARG(float), "ImagizeColorChannelBweight", &MOC_CHANNEL, OPTEXP_CORE,
00056     "Weight to assign to the Beta component of the Imagize color channel",
00057     "imgz-b-weight", '\0', "<float>", "1.0" };
00058 
00059 const ModelOptionDef OPT_ImagizeColorChannelLweight =
00060   { MODOPT_ARG(float), "ImagizeColorChannelLweight", &MOC_CHANNEL, OPTEXP_CORE,
00061     "Weight to assign to the Led component of the Imagize color channel",
00062     "imgz-l-weight", '\0', "<float>", "1.0" };
00063 
00064 // ######################################################################
00065 // ImagizeColorChannel member definitions:
00066 // ######################################################################
00067 
00068 ImagizeColorChannel::ImagizeColorChannel(OptionManager& mgr) :
00069   ComplexChannel(mgr, "ImagizeComposite", "ImagizeComposite", IMGZCOLOR),
00070   itsAweight(&OPT_ImagizeColorChannelAweight, this),
00071   itsBweight(&OPT_ImagizeColorChannelBweight, this),
00072   itsLweight(&OPT_ImagizeColorChannelLweight, this),
00073   itsA(new ImagizeAlphaChannel(getManager(), true)),
00074   itsB(new ImagizeBetaChannel(getManager(), true)),
00075   itsL(new ImagizeLedChannel(getManager(), true))
00076 {
00077 GVX_TRACE(__PRETTY_FUNCTION__);
00078 
00079   this->addSubChan(itsA);
00080   this->addSubChan(itsB);
00081   this->addSubChan(itsL);
00082 }
00083 
00084 // ######################################################################
00085 ImagizeAlphaChannel& ImagizeColorChannel::alpha() const
00086 {
00087 GVX_TRACE(__PRETTY_FUNCTION__);
00088   return *itsA;
00089 }
00090 
00091 // ######################################################################
00092 ImagizeBetaChannel& ImagizeColorChannel::beta() const
00093 {
00094 GVX_TRACE(__PRETTY_FUNCTION__);
00095   return *itsB;
00096 }
00097 
00098 // ######################################################################
00099 ImagizeLedChannel& ImagizeColorChannel::led() const
00100 {
00101 GVX_TRACE(__PRETTY_FUNCTION__);
00102   return *itsL;
00103 }
00104 
00105 // ######################################################################
00106 ImagizeColorChannel::~ImagizeColorChannel()
00107 {
00108 GVX_TRACE(__PRETTY_FUNCTION__);
00109 }
00110 
00111 // ######################################################################
00112 void ImagizeColorChannel::start1()
00113 {
00114   LINFO("Using a weight of %f for Alpha subchannel", itsAweight.getVal());
00115   setSubchanTotalWeight(*itsA, itsAweight.getVal());
00116 
00117   LINFO("Using a weight of %f for Beta subchannel", itsBweight.getVal());
00118   setSubchanTotalWeight(*itsB, itsBweight.getVal());
00119 
00120   LINFO("Using a weight of %f for LED subchannel", itsLweight.getVal());
00121   setSubchanTotalWeight(*itsL, itsLweight.getVal());
00122 }
00123 
00124 // ######################################################################
00125 void ImagizeColorChannel::doInput(const InputFrame& inframe)
00126 {
00127 GVX_TRACE(__PRETTY_FUNCTION__);
00128 
00129   // get the A, B, L components (which just come in from the camera as
00130   // R, G, B, respectively):
00131   LINFO("Converting input image to Alpha-Beta-LED colors.");
00132   Image<byte> aimg, bimg, limg;
00133   getComponents(inframe.colorByte(), aimg, bimg, limg);
00134 
00135   // convert to floats:
00136   Image<float> a = aimg, b = bimg, l = limg;
00137 
00138   // feed our subchannels with float versions of the images:
00139   itsA->input(InputFrame::fromGrayFloat(&a, inframe.time(), &inframe.clipMask(), inframe.pyrCache()));
00140   itsB->input(InputFrame::fromGrayFloat(&b, inframe.time(), &inframe.clipMask(), inframe.pyrCache()));
00141   itsL->input(InputFrame::fromGrayFloat(&l, inframe.time(), &inframe.clipMask(), inframe.pyrCache()));
00142   LINFO("Imagize Color channel ok.");
00143 }
00144 
00145 // ######################################################################
00146 /* So things look consistent in everyone's emacs... */
00147 /* Local Variables: */
00148 /* indent-tabs-mode: nil */
00149 /* End: */
Generated on Sun May 8 08:04:35 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3