00001 /*!@file Image/LevelSpec.H a utility class for use with SingleChannel */ 00002 00003 // //////////////////////////////////////////////////////////////////// // 00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2001 by the // 00005 // 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@klab.caltech.edu> 00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Image/LevelSpec.H $ 00035 // $Id: LevelSpec.H 5773 2005-10-20 21:45:34Z rjpeters $ 00036 // 00037 00038 #ifndef LEVELSPEC_H_DEFINED 00039 #define LEVELSPEC_H_DEFINED 00040 00041 #include "Util/Types.H" // for uint 00042 00043 #include <string> // for string conversions 00044 00045 // ###################################################################### 00046 //! A utility class for use with SingleChannel. 00047 /*! LevelSpec specifies a set of center/surround pairings, by tracking two 00048 min/max ranges: one for <i>level</a>s, and one for <i>delta</i>s. Note 00049 that both of these ranges are <i>inclusive</i> ranges; both the min and 00050 max values are valid elements. The levels refer to depth levels in a 00051 Pyramid, and the deltas refer to differences between the center and 00052 surround levels in a centerSurround() operation. LevelSpec also maps 00053 these ranges into a singe range 0..maxIndex(), so that all pairings of 00054 level/delta can be accessed in a 1-D array, for example. */ 00055 class LevelSpec 00056 { 00057 public: 00058 //! Unitialized constructor, all internal values to 0 00059 LevelSpec(); 00060 00061 //! Constructor 00062 LevelSpec(const uint levmin, const uint levmax, 00063 const uint deltmin, const uint deltmax, 00064 const uint maplevel); 00065 00066 //! (re-)initialization 00067 void init(const uint levmin, const uint levmax, 00068 const uint deltmin, const uint deltmax, 00069 const uint maplevel); 00070 00071 // Default copy-constructor OK 00072 00073 //! Get the minimum center level (inclusive). 00074 uint levMin() const; 00075 //! Get the maximum center level (inclusive). 00076 uint levMax() const; 00077 //! Get the minimum surround minus center level difference (inclusive). 00078 uint delMin() const; 00079 //! Get the maximum surround minus center level difference (inclusive). 00080 uint delMax() const; 00081 00082 //! Get the level at which the feature map is built. 00083 uint mapLevel() const; 00084 00085 //! Get the maximum index that can be returned from csToIndex(). 00086 uint maxIndex() const; 00087 //! Get the maximum surround level that will be used. 00088 uint maxDepth() const; 00089 00090 //! Query if the given array index is valid for this object. 00091 bool indexOK(uint index) const; 00092 00093 //! Query if the given center level is valid for this object. 00094 bool clevOK(uint centerlev) const; 00095 00096 //! Query if the given surround level is valid for this object. 00097 bool slevOK(uint surroundlev) const; 00098 00099 //! Query if the given surround-center delta is valid for this object. 00100 bool delOK(uint delta) const; 00101 00102 //! Query if the given center/surround levels are valid for this object. 00103 /*! The "cs" prefix is a mnemonic to indicate that the center argument 00104 precedes the surround argument. */ 00105 bool csOK(uint centerlev, uint surroundlev) const; 00106 00107 //! Compute an array index for a given center/surround pairing. 00108 /*! Return the array index in 0..maxIndex that corresponds to the given 00109 center/surround levels. The "cs" prefix is a mnemonic to indicate 00110 that the center argument precedes the surround argument. */ 00111 uint csToIndex(uint centerlev, uint surroundlev) const; 00112 00113 //! Compute the center/surround pairing corresponding to an array index. 00114 void indexToCS(uint index, uint& centerlev, uint& surroundlev) const; 00115 00116 //! Equality operator 00117 bool operator==(const LevelSpec& that) const; 00118 00119 //! Inequality operator 00120 bool operator!=(const LevelSpec& that) const 00121 { return !(*this == that); } 00122 00123 private: 00124 //! levelMin <= level <= levelMax 00125 uint itsLevMin; 00126 //! levelMin <= level <= levelMax 00127 uint itsLevMax; 00128 //! deltaMin <= delta <= deltaMax 00129 uint itsDelMin; 00130 //! deltaMin <= delta <= deltaMax 00131 uint itsDelMax; 00132 //! the pyramid level at which the feature map is taken 00133 uint itsMapLevel; 00134 //! 0 <= index(.,.) < maxindex 00135 uint itsMaxIndex; 00136 //! depth of pyramids 00137 uint itsMaxDepth; 00138 }; 00139 00140 //! LevelSpec overload: format is "<int>-<int>,<int>-<int>,<int>" 00141 /*! Format corresponds to "levmin-levmax,delmin-delmax,maplevel" */ 00142 std::string convertToString(const LevelSpec& val); 00143 00144 //! LevelSpec overload: format is "<int>-<int>,<int>-<int>,<int>" 00145 void convertFromString(const std::string& str, LevelSpec& val); 00146 00147 00148 // ###################################################################### 00149 /* So things look consistent in everyone's emacs... */ 00150 /* Local Variables: */ 00151 /* indent-tabs-mode: nil */ 00152 /* End: */ 00153 00154 #endif // !LEVELSPEC_H_DEFINED