00001 /*!@file CINNIC/CINNICstatsRun.H Run some stats with CINNIC */ 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: Nathan Mundhenk <mundhenk@usc.edu> 00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/CINNIC/CINNICstatsRun.H $ 00035 // $Id: CINNICstatsRun.H 9412 2008-03-10 23:10:15Z farhan $ 00036 // 00037 00038 // ############################################################ 00039 // ############################################################ 00040 // ##### ---CINNIC--- 00041 // ##### Contour Integration: 00042 // ##### T. Nathan Mundhenk nathan@mundhenk.com 00043 // ############################################################ 00044 // ############################################################ 00045 00046 #ifndef CINNICSTATSRUN_H_DEFINED 00047 #define CINNICSTATSRUN_H_DEFINED 00048 00049 #include "CINNIC/statsIncl.H" 00050 00051 class CINNICstatsRun 00052 { 00053 protected: 00054 //! the output file 00055 std::string statsFile; 00056 //! used for something 00057 int ii,jj; 00058 //! variables that used to be defined, but are now in stats.conf 00059 int decSize,unEvenDec,lowThresh,highThresh,chopVal; 00060 //! This is the number of images to be compaired 00061 int imageCount,zeroCount; 00062 //! these are used for high quality comparison images 00063 int qualityImage,qChop; 00064 //! this is true if the image is to be resized 00065 int doResize; 00066 //! the number of salience points to find 00067 int pointsNum; 00068 //! width of circles to draw out in sal map 00069 int circRad; 00070 //! threshold at which to consider a point 00071 int rankThresh; 00072 //! this tells if point and flood should pre-process image # 00073 int preProcessPNF; 00074 //! this is set if you want to use draw disk rather then flood. Use w caution 00075 int useDrawDisk; 00076 //! the size of the disk to be drawn (r) 00077 int diskSize; 00078 //! use this to produce thick mono color circle plots in figure 00079 int monoColor; 00080 //! offset for center of image element in output image 00081 int centerOffset; 00082 //! how much to attenuate borders for edge effects 00083 int edgeAtten; 00084 //! the total error ratio, mean Chamfer34 value 00085 float totalErrorRatio, meanChamfer; 00086 //! the mean error ratio, other stats 00087 float totalMeanError,totalStdError,maxMean,minMean; 00088 //! The total euclidian distance 00089 float totEucDist; 00090 //! the mean euclidian distance, other stats 00091 float meanEucDist,stdEucDist,maxEuc,minEuc; 00092 //! total regression 00093 float totReg; 00094 //! mean regression, other stats 00095 float meanReg,stdReg,maxReg,minReg; 00096 //! flood variabels for image flooding 00097 float floodThresh, floodVal; 00098 //! stats values for point and flood 00099 float foundTotal,foundMean,foundSTD,rankTotal,rankMean,rankSTD; 00100 //! values for Polat and Sagi 00101 float PSError; 00102 //! mu1 and mu2 as the population mean 00103 float mu1, mu2; 00104 //! Image to test 00105 Image<float> testImage; 00106 //! Image to compare against 00107 Image<float> compImage; 00108 //! sal map for PointAndFlood 00109 Image<float> salMap; 00110 //! Temp image 1 00111 Image<byte> tempImage1; 00112 //! Temp image 2 00113 Image<byte> tempImage2; 00114 //! Temp image 1c 00115 Image<PixRGB <byte> > tempImage1c; 00116 //! temp image 1cf 00117 Image<PixRGB <float> > tempImage1cf; 00118 //! output image of points 00119 Image<PixRGB <float> > outImageTemplate; 00120 //! output image of points 00121 Image<PixRGB <float> > outImageSource; 00122 //! track the mask image for stats 00123 Image<float> maskImage; 00124 //! the count of error pixels in each image 00125 std::vector<int> errorCount; 00126 //! the count of total positive pixels in each image 00127 std::vector<int> totCount; 00128 //! The total pixel value (/n = average pixel value) 00129 std::vector<float> totalVal; 00130 //! The ratio of error pixels to non-error pixels 00131 std::vector<float> errorRatio; 00132 //! place holder for vectored images 00133 std::vector<float> testImageVector; 00134 //! place holder for vectored images 00135 std::vector<float> compImageVector; 00136 //! More stats 00137 std::vector<float> testMean; 00138 //! More stats 00139 std::vector<float> testStd; 00140 //! More stats 00141 std::vector<float> compMean; 00142 //! More stats 00143 std::vector<float> compStd; 00144 //! Regression 00145 std::vector<float> regression; 00146 //!Eucliduan Distance between images 00147 std::vector<double> eucDist; 00148 //! General stats object 00149 stats<float> Stats; 00150 //! Another stats object 00151 stats<double> dStats; 00152 //! holds max n points from image 00153 std::vector<Point2D<int> > pointVec; 00154 //! holds max points for all images 00155 std::vector< std::vector<Point2D<int> > > maxPointList; 00156 //! holds max val for all chamfer34 processed images 00157 std::vector<float> postChamferVal; 00158 //! holds the count of correct salient points 00159 std::vector<float> pointsFound; 00160 //! how many images found this number of salient points 00161 std::vector<int> pointsFoundNum; 00162 //! holds the rank of the most salient point on the object 00163 std::vector<float> pointRank; 00164 //! how many images are at this rank 00165 std::vector<int> pointRankNum; 00166 //Point2D<int> *point2D = new Point2D<int>(); 00167 Point2D<int> *point2D; 00168 //Point2D<int> *oldPoint; 00169 //! a lovelly pixRGB instance 00170 PixRGB<float> pixRGB; 00171 //! std::vector for number of candidate pixels for point and flood 00172 std::vector<long> candPixels; 00173 //! std::vector for the number of real pixels on the contour 00174 std::vector<long> realPixels; 00175 //! Vector to hold p for striking a pixel 00176 std::vector<double> strikeP; 00177 //! Bernoulli distribution P for the nth strike 00178 std::vector<double> bernoulliP; 00179 public: 00180 //! default constructor 00181 CINNICstatsRun(); 00182 00183 //! default destructor 00184 ~CINNICstatsRun(); 00185 00186 //! sets the config and loads files 00187 /*! Read in the configuration file values 00188 @param config the parsed config file 00189 */ 00190 void setConfig(readConfig &config, readConfig &config2); 00191 00192 //! sets a bunch of parameters and junk 00193 /*! called automatically by constructor, but needs to be called if one 00194 of the methods such as runStandardStats or runPointAndFlood is called 00195 more then once. 00196 */ 00197 void setStuff(readConfig &fileList); 00198 00199 //! single file option 00200 void setStuff(); 00201 00202 //! run standard stats battery on images with contour traces 00203 /*! this method finds how similar an image is to another image based 00204 upon its corralation, euclidian distance and mean error. It takes in 00205 two image files and does the compairison. It can run a whole batch of 00206 images (what its made to do) by setting up the file names in a config 00207 file 00208 @param fileList This is the parsed list of files 00209 */ 00210 void runStandardStats(readConfig &fileList); 00211 00212 //! run salience point analysis on image data 00213 /*! This method will attempt to find the most salient points in an 00214 input image, then it will compair thos points to points that are 00215 expected. It does this by first finding a point, then finding 00216 its distance to a contour using champher, then the point are is flooded 00217 to prevent it from being found again. This is repeated n times 00218 @param fileList This is the list of input images 00219 */ 00220 void runPointAndFlood(readConfig &fileList, const char* param); 00221 00222 //! Run through the input image. Find likelyhood of a random match 00223 /*! This method will take the compare image and find what is the 00224 p that a random 00225 pixel will land on a pixel that is a contour candidate pixel. 00226 Takes in pointers 00227 that return p, the number of candidate pixels and the total 00228 number of pixels 00229 @param likelyhood This is the p that a random pixel will fall on a candidate contour 00230 @param posRegionCount This is the number of candidate pixels in the image 00231 @param totalCount This is the total number of pixels in the image 00232 */ 00233 void randomMatch(float *likelyhood,long *posRegionCount, long *totalCount); 00234 00235 //! method for comp image pre-processing 00236 void preProcess(); 00237 00238 //! checks what to do about images that are of different size 00239 void checkSize(); 00240 00241 //! this is a table of colors to be used for circles 00242 PixRGB<float> colorTable(int i); 00243 00244 //! pointAndFlood on one image, no stats 00245 void pointAndFloodImage(Image<float> test_image, Image<float> sal_map 00246 ,int points,char* filename, float floodv, float floodt); 00247 00248 //! pointAndFlood on one image, no stats 00249 void pointAndFloodImage(Image<float> test_image, Image<float> sal_map 00250 ,char* filename); 00251 00252 //! this is the core to point and flood 00253 void pointAndFlood(const char* filename,int i,bool standalone); 00254 00255 //! this will take in an image and make a 2AFC, see Itti Thesis 145-149 00256 /*! This takes in an image and performs a simulation of Polat and Sagi 00257 1994 two alternative forced choice. It takes in an image and defines 00258 an error in judgement based upon the 2AFC paradigm. It returns the 00259 error. This should be compaired to the staircase method described 00260 by Polat and Sagi in obtaining threshold. 00261 */ 00262 float polatSagi2AFC(Image<float> targetImage,Image<float> notargetImage); 00263 //! Return mu1 00264 float getMu1(); 00265 //! Return mu2 00266 float getMu2(); 00267 00268 }; 00269 00270 00271 00272 #endif 00273 00274 // ###################################################################### 00275 /* So things look consistent in everyone's emacs... */ 00276 /* Local Variables: */ 00277 /* indent-tabs-mode: nil */ 00278 /* End: */