00001 /*!@file Channels/IntegerOrientationChannel.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/Channels/IntegerOrientationChannel.C $ 00035 // $Id: IntegerOrientationChannel.C 8199 2007-03-30 17:58:46Z rjpeters $ 00036 // 00037 00038 #ifndef CHANNELS_INTEGERORIENTATIONCHANNEL_C_DEFINED 00039 #define CHANNELS_INTEGERORIENTATIONCHANNEL_C_DEFINED 00040 00041 #include "Channels/IntegerOrientationChannel.H" 00042 00043 #include "Channels/ChannelOpts.H" 00044 #include "Channels/IntegerSimpleChannel.H" 00045 #include "Component/OptionManager.H" 00046 #include "Image/ImageSetOps.H" 00047 #include "Image/IntegerMathOps.H" 00048 #include "Image/PyramidCache.H" 00049 #include "Util/sformat.H" 00050 #include "rutz/mutex.h" 00051 #include "rutz/trace.h" 00052 00053 // ###################################################################### 00054 // IntegerOrientationChannel member definitions: 00055 // ###################################################################### 00056 00057 // ###################################################################### 00058 IntegerOrientationChannel:: 00059 IntegerOrientationChannel(OptionManager& mgr, 00060 nub::ref<IntegerMathEngine> eng) : 00061 IntegerComplexChannel(mgr, "Integer Orientation", 00062 "int-orientation", ORI, eng), 00063 itsNumOrients(&OPT_NumOrientations, this) // see Channels/ChannelOpts.{H,C} 00064 { 00065 GVX_TRACE(__PRETTY_FUNCTION__); 00066 // let's build our channels; we may have to re-build them if 00067 // itsNumOrient get changed on us before we start(): 00068 buildSubChans(); 00069 } 00070 00071 // ###################################################################### 00072 void IntegerOrientationChannel::buildSubChans() 00073 { 00074 GVX_TRACE(__PRETTY_FUNCTION__); 00075 // kill any subchans we may have had... 00076 this->removeAllSubChans(); 00077 00078 // let's instantiate our Gabor subchannels now that we know how many 00079 // we want. They will inherit the current values (typically 00080 // post-command-line parsing) of all their options as they are 00081 // constructed: 00082 LINFO("Using %d orientations spanning [0..180]deg", itsNumOrients.getVal()); 00083 for (uint ori = 0; ori < itsNumOrients.getVal(); ++ori) 00084 { 00085 const double theta = 00086 180.0 * double(ori) / double(itsNumOrients.getVal()); 00087 00088 nub::ref<IntegerSimpleChannel> chan 00089 (new IntegerSimpleChannel 00090 (getManager(), 00091 sformat("Integer Gabor (%d)", int(theta)), 00092 sformat("int-ori_%u", ori), UNKNOWN, 00093 rutz::make_shared(new IntgOrientedPyrBuilder 00094 (9, theta, this->getImath())), 00095 this->getMathEngine())); 00096 00097 chan->setNormalizeOutput(true); 00098 00099 this->addSubChan(chan); 00100 00101 // let's export options on our newly built channels: 00102 chan->exportOptions(MC_RECURSE); 00103 } 00104 } 00105 00106 // ###################################################################### 00107 void IntegerOrientationChannel::paramChanged(ModelParamBase* const param, 00108 const bool valueChanged, 00109 ParamClient::ChangeStatus* status) 00110 { 00111 GVX_TRACE(__PRETTY_FUNCTION__); 00112 IntegerComplexChannel::paramChanged(param, valueChanged, status); 00113 00114 // if the param is our number of orientations and it has become 00115 // different from our number of channels, let's reconfigure: 00116 if (param == &itsNumOrients && valueChanged) 00117 buildSubChans(); 00118 } 00119 00120 // ###################################################################### 00121 IntegerOrientationChannel::~IntegerOrientationChannel() 00122 { 00123 GVX_TRACE(__PRETTY_FUNCTION__); 00124 } 00125 00126 // ###################################################################### 00127 IntegerSimpleChannel& IntegerOrientationChannel::gabor(const uint idx) const 00128 { 00129 GVX_TRACE(__PRETTY_FUNCTION__); 00130 // Since we are dynamic_cast'ing a reference, this operation will 00131 // either succeed or throw an exception. 00132 return *(dynCast<IntegerSimpleChannel>(subChan(idx))); 00133 } 00134 00135 // ###################################################################### 00136 void IntegerOrientationChannel::doInputInt(const IntegerInput& inp, 00137 const SimTime& t, 00138 PyramidCache<int>* cache, 00139 const Image<byte>& clipMask) 00140 { 00141 GVX_TRACE(__PRETTY_FUNCTION__); 00142 00143 ASSERT(inp.grayInt().initialized()); 00144 00145 if (numChans() == 0) 00146 return; 00147 00148 rutz::mutex_lock_class lock; 00149 if (cache && cache->laplacian9.beginSet(inp.grayInt(), &lock)) 00150 { 00151 cache->laplacian9.endSet 00152 (inp.grayInt(), 00153 intgBuildPyrLaplacian 00154 (inp.grayInt(), gabor(0).getMinPyrLevel(), 00155 gabor(0).getMaxPyrLevel(), 9, 00156 this->getImath()), 00157 &lock); 00158 } 00159 00160 for (uint i = 0; i < numChans(); ++i) 00161 { 00162 gabor(i).inputInt(inp, t, cache, clipMask); 00163 LINFO("Orientation pyramid (%d/%d) ok.", i+1, numChans()); 00164 } 00165 } 00166 00167 // ###################################################################### 00168 /* So things look consistent in everyone's emacs... */ 00169 /* Local Variables: */ 00170 /* mode: c++ */ 00171 /* indent-tabs-mode: nil */ 00172 /* End: */ 00173 00174 #endif // CHANNELS_INTEGERORIENTATIONCHANNEL_C_DEFINED