SaliencyMapFeatureExtractor.C

Go to the documentation of this file.
00001 /*!@file TIGS/SaliencyMapFeatureExtractor.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: Rob Peters <rjpeters at usc dot edu>
00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/TIGS/SaliencyMapFeatureExtractor.C $
00035 // $Id: SaliencyMapFeatureExtractor.C 10845 2009-02-13 08:49:12Z itti $
00036 //
00037 
00038 #ifndef TIGS_SALIENCYMAPFEATUREEXTRACTOR_C_DEFINED
00039 #define TIGS_SALIENCYMAPFEATUREEXTRACTOR_C_DEFINED
00040 
00041 #include "TIGS/SaliencyMapFeatureExtractor.H"
00042 
00043 #include "Component/ModelOptionDef.H"
00044 #include "Image/fancynorm.H"
00045 #include "Neuro/VisualCortex.H"
00046 #include "Neuro/VisualCortexConfigurator.H"
00047 #include "TIGS/TigsOpts.H"
00048 #include "rutz/trace.h"
00049 
00050 // Used by: VisualCortexFeatureExtractor
00051 static const ModelOptionDef OPT_SmfxVcType =
00052   { MODOPT_ARG_STRING, "SmfxVcType", &MOC_TIGS, OPTEXP_CORE,
00053     "VisualCortex type for the saliency-map feature extractor",
00054     "smfx-vc-type", '\0', "<string>", "Std" };
00055 
00056 // Used by: SaliencyMapFeatureExtractor
00057 static const ModelOptionDef OPT_SmfxNormType =
00058   { MODOPT_ARG(MaxNormType), "SmfxNormType", &MOC_TIGS, OPTEXP_CORE,
00059     "Normalization type for the saliency-map feature extractor",
00060     "smfx-norm-type", '\0', "<string>", "Fancy" };
00061 
00062 // Used by: SaliencyMapFeatureExtractor
00063 static const ModelOptionDef OPT_SmfxRescale512 =
00064   { MODOPT_FLAG, "SmfxRescale512", &MOC_TIGS, OPTEXP_CORE,
00065     "Whether to rescale smfx to 512x512 before computing the saliency map",
00066     "smfx-rescale-512", '\0', "", "true" };
00067 
00068 // ######################################################################
00069 SaliencyMapFeatureExtractor::
00070 SaliencyMapFeatureExtractor(OptionManager& mgr)
00071   :
00072   FeatureExtractor(mgr, "uninitialized"),
00073   itsNormType(&OPT_SmfxNormType, this),
00074   itsVcType(&OPT_SmfxVcType, this),
00075   itsRescale512(&OPT_SmfxRescale512, this),
00076   itsVCC(new VisualCortexConfigurator(mgr))
00077 {
00078   this->addSubComponent(itsVCC);
00079 
00080   this->setCheckFrequency(0);
00081 }
00082 
00083 // ######################################################################
00084 SaliencyMapFeatureExtractor::
00085 ~SaliencyMapFeatureExtractor() {}
00086 
00087 // ######################################################################
00088 void SaliencyMapFeatureExtractor::
00089 paramChanged(ModelParamBase* const param,
00090              const bool valueChanged,
00091              ParamClient::ChangeStatus* status)
00092 {
00093   FeatureExtractor::paramChanged(param, valueChanged, status);
00094 
00095   if (param == &itsVcType)
00096     {
00097       itsVCC->setModelParamString("VisualCortexType",
00098                                   itsVcType.getVal());
00099 
00100       itsVCC->getVC()->setModelParamVal
00101         ("MaxNormType", itsNormType.getVal(), MC_RECURSE);
00102 
00103       LINFO("set SaliencyMapFeatureExtractor to vctype=%s",
00104             itsVcType.getVal().c_str());
00105     }
00106 
00107   const char* pfx = itsRescale512.getVal() ? "smfx" : "smofx";
00108 
00109   if (itsVcType.getValString() == "Std")
00110     this->changeFxName(pfx + itsNormType.getValString());
00111   else
00112     this->changeFxName(pfx + itsNormType.getValString()
00113                        + itsVcType.getValString());
00114 }
00115 
00116 // ######################################################################
00117 Dims SaliencyMapFeatureExtractor::smDims() const
00118 {
00119   if (itsRescale512.getVal())
00120     {
00121       return Dims(512,512);
00122     }
00123   else
00124     {
00125       return Dims(640,480);
00126     }
00127 }
00128 
00129 // ######################################################################
00130 Image<float> SaliencyMapFeatureExtractor::
00131 doExtract(const TigsInputFrame& fin)
00132 {
00133   GVX_TRACE(__PRETTY_FUNCTION__);
00134 
00135   if (fin.isGhost())
00136     LFATAL("SaliencyMapFeatureExtractor needs non-ghost frames");
00137 
00138   LFATAL("FIXME");
00139   /*
00140   if (itsRescale512.getVal())
00141     {
00142       ASSERT(fin.rgb().getDims() == Dims(512, 512));
00143       itsVCC->getVC()->input(InputFrame::fromRgb(&fin.rgb(), fin.t()));
00144     }
00145   else
00146     {
00147       ASSERT(fin.origframe().getDims() == Dims(640, 480));
00148       itsVCC->getVC()->input(InputFrame::fromRgb(&fin.origframe(), fin.t()));
00149     }
00150 
00151   Image<float> result = itsVCC->getVC()->getOutput();
00152   result *= 5e9f;
00153 
00154   return result;
00155   */
00156   return Image<float>();
00157 }
00158 
00159 // ######################################################################
00160 void SaliencyMapFeatureExtractor::start1()
00161 {
00162   itsVCC->getVC()->setModelParamVal
00163     ("MaxNormType", itsNormType.getVal(), MC_RECURSE);
00164 }
00165 
00166 // ######################################################################
00167 /* So things look consistent in everyone's emacs... */
00168 /* Local Variables: */
00169 /* mode: c++ */
00170 /* indent-tabs-mode: nil */
00171 /* End: */
00172 
00173 #endif // TIGS_SALIENCYMAPFEATUREEXTRACTOR_C_DEFINED
Generated on Sun May 8 08:42:23 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3