00001 /*!@file BeoSub/BeoSubSaliency.H A class for quick-and-dirty saliency mapping */ 00002 00003 // //////////////////////////////////////////////////////////////////// // 00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2003 // 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: Zack Gossman <gossman@usc.edu> 00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/BeoSub/BeoSubSaliency.H $ 00035 // $Id: BeoSubSaliency.H 9412 2008-03-10 23:10:15Z farhan $ 00036 // 00037 00038 #ifndef BEOSUBSALIENCY_H_DEFINED 00039 #define BEOSUBSALIENCY_H_DEFINED 00040 00041 #include "Component/ModelManager.H" 00042 #include "Image/ColorOps.H" 00043 #include "Image/Image.H" 00044 #include "Image/ImageSet.H" 00045 #include "Image/MathOps.H" 00046 #include "Image/DrawOps.H" 00047 #include "Image/FilterOps.H" 00048 #include "Image/Pixels.H" 00049 #include "Image/PyramidOps.H" 00050 #include "Image/ShapeOps.H" 00051 #include "Image/Transforms.H" 00052 #include "Image/fancynorm.H" 00053 #include "Util/Types.H" 00054 #include "GUI/XWindow.H" 00055 #include "Image/colorDefs.H" 00056 00057 #include <pthread.h> 00058 #include <cstdlib> 00059 #include <unistd.h> 00060 #include <list> 00061 00062 // ###################################################################### 00063 // ##### Global options: 00064 // ###################################################################### 00065 00066 #define sml 2 00067 #define delta_min 3 00068 #define delta_max 4 00069 #define level_min 0 00070 #define level_max 2 00071 #define maxdepth (level_max + delta_max + 1) 00072 #define normtyp (VCXNORM_MAXNORM) 00073 00074 // relative feature weights: 00075 #define IWEIGHT 0.7 00076 #define CWEIGHT 1.0 00077 #define OWEIGHT 1.0 00078 #define FWEIGHT 4.0 00079 #define SWEIGHT 2.0 00080 00081 // image size vars 00082 #define IMAGEWIDTH 160 00083 #define IMAGEHEIGHT 120 00084 00085 // action definitions CHANGE TO ENUM? FIX? 00086 #define RETINA 1 00087 #define WINNER 2 00088 #define LUMINANCE 3 00089 #define REDGREEN 4 00090 #define BLUEYELLOW 5 00091 #define ORI0 6 00092 #define ORI45 7 00093 #define ORI90 8 00094 #define ORI135 9 00095 #define CMAP 10 00096 #define FLICKER 11 00097 #define INTENSITY 12 00098 #define SKINHUE 13 00099 00100 struct jobData{ 00101 jobData() { }; 00102 00103 jobData(const int jt, const PyramidType pt, const float w, 00104 const float ori = 0.0F) : 00105 jobType(jt), ptyp(pt), weight(w), orientation(ori) { } 00106 00107 int jobType; 00108 PyramidType ptyp; 00109 float weight; 00110 float orientation; 00111 }; 00112 00113 class BeoSubSaliency : public ModelComponent 00114 { 00115 public: 00116 00117 // ###################################################################### 00118 /*! @name Constructors and Destructors */ 00119 //@{ 00120 00121 //! Constructor 00122 BeoSubSaliency(OptionManager& mgr, 00123 const std::string& descrName = "SaliencyMT", 00124 const std::string& tagName = "SaliencyMT"); 00125 00126 //! Destructor 00127 ~BeoSubSaliency(); 00128 00129 //@} 00130 00131 // ###################################################################### 00132 /*! @name member functions */ 00133 //@{ 00134 00135 //! Setup up with image to be processed and build the job queue 00136 Point2D<int> run(Image< PixRGB<byte> > img, bool debug = false); 00137 00138 //! Compute a conspicuity map from an image 00139 void computeCMAP(); 00140 //@} 00141 00142 protected: 00143 OModelParam<uint> itsNumThreads; //!< Number of worker threads to use 00144 00145 private: 00146 Image< PixRGB<byte> > colima; // current color image 00147 Image<float> lum; //curent luminance image 00148 Image<byte> r, g, b, y; //curent RGBY images 00149 Image<float> previma; // previous float image 00150 Image<float> outmap; // output saliency map 00151 Image<float> skinima; //skin hue map 00152 00153 // get prepared to grab, communicate, display, etc: 00154 00155 Point2D<int> win, winsm; // coordinates of attended location 00156 float maxval; 00157 00158 PyramidType ptyp; 00159 00160 //xwin stuff 00161 rutz::shared_ptr<XWindow> wini, wino; 00162 bool debugmode; 00163 bool hasRun; 00164 00165 //job stuff 00166 std::list<jobData> jobQueue; 00167 bool jobsReady; 00168 bool dataReady; 00169 int jobsDone; 00170 int totalJobs; 00171 bool gotRGBY; bool gotLum; 00172 00173 //thread stuff 00174 pthread_t *worker; 00175 pthread_mutex_t jobLock, condLock, mapLock; 00176 pthread_cond_t jobCond; 00177 }; 00178 00179 #endif 00180 00181 // ###################################################################### 00182 /* So things look consistent in everyone's emacs... */ 00183 /* Local Variables: */ 00184 /* indent-tabs-mode: nil */ 00185 /* End: */