00001 /*!@file CINNIC/CINNICstatsRun.C run anal. of 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: Laurent Itti <itti@usc.edu> 00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/CINNIC/CINNICstatsRun.C $ 00035 // $Id: CINNICstatsRun.C 14376 2011-01-11 02:44:34Z pez $ 00036 // 00037 00038 // ############################################################ 00039 // ############################################################ 00040 // ##### ---CINNIC--- 00041 // ##### Contour Integration: 00042 // ##### T. Nathan Mundhenk nathan@mundhenk.com 00043 // ############################################################ 00044 // ############################################################ 00045 #include "CINNIC/CINNICstatsRun.H" 00046 00047 #include "Util/Assert.H" 00048 #include "Image/DrawOps.H" 00049 #include "Image/MathOps.H" 00050 #include "Image/Transforms.H" 00051 00052 #include <fstream> 00053 00054 CINNICstatsRun::CINNICstatsRun() 00055 { 00056 } 00057 00058 CINNICstatsRun::~CINNICstatsRun() 00059 { 00060 } 00061 00062 00063 00064 void CINNICstatsRun::setConfig(readConfig &config, readConfig &config2) 00065 { 00066 /* FORMAT... 00067 iterations = (int)config.getItemValueF("iterations"); 00068 ... 00069 */ 00070 LINFO("READING CONFIG VALUES"); 00071 decSize = (int)config.getItemValueF("decSize"); 00072 unEvenDec = (int)config.getItemValueF("unEvenDec"); 00073 lowThresh = (int)config.getItemValueF("lowThresh"); 00074 highThresh = (int)config.getItemValueF("highThresh"); 00075 chopVal = (int)config.getItemValueF("chopVal"); 00076 pointsNum = (int)config.getItemValueF("pointsNum"); 00077 circRad = (int)config.getItemValueF("circRad"); 00078 floodThresh = config.getItemValueF("floodThresh"); 00079 floodVal = config.getItemValueF("floodVal"); 00080 qualityImage = (int)config.getItemValueF("qualityImage"); 00081 qChop = (int)config.getItemValueF("qChop"); 00082 doResize = (int)config.getItemValueF("doResize"); 00083 rankThresh = (int)config.getItemValueF("rankThresh"); 00084 preProcessPNF = (int)config.getItemValueF("preProcessPNF"); 00085 useDrawDisk = (int)config.getItemValueF("useDrawDisk"); 00086 diskSize = (int)config.getItemValueF("diskSize"); 00087 statsFile = config.getItemValueS("statsFile"); 00088 monoColor = (int)config.getItemValueF("monoColor"); 00089 PSError = config2.getItemValueF("PSError"); 00090 centerOffset = (int)config.getItemValueF("centerOffset"); 00091 edgeAtten = (int)config.getItemValueF("edgeAtten"); 00092 } 00093 00094 void CINNICstatsRun::setStuff(readConfig &fileList) 00095 { 00096 tempImage1c.resize(1,1); 00097 tempImage2.resize(1,1); 00098 salMap.resize(1,1); 00099 point2D = new Point2D<int>; 00100 pointVec.resize(5,*point2D); 00101 maxPointList.resize(fileList.itemCount(),pointVec); 00102 postChamferVal.resize(fileList.itemCount(),0.0F); 00103 errorCount.resize(fileList.itemCount(),0); 00104 totCount.resize(fileList.itemCount(),0); 00105 totalVal.resize(fileList.itemCount(),0.0F); 00106 errorRatio.resize(fileList.itemCount(),0.0F); 00107 testMean.resize(fileList.itemCount(),0.0F); 00108 testStd.resize(fileList.itemCount(),0.0F); 00109 compMean.resize(fileList.itemCount(),0.0F); 00110 compStd.resize(fileList.itemCount(),0.0F); 00111 regression.resize(fileList.itemCount(),0.0F); 00112 eucDist.resize(fileList.itemCount(),0.0F); 00113 pointsFound.resize(fileList.itemCount(),0); 00114 pointsFoundNum.resize(pointsNum,0); 00115 pointRank.resize(fileList.itemCount(),-1); 00116 pointRankNum.resize(pointsNum,0); 00117 candPixels.resize(pointsNum,0); 00118 realPixels.resize(pointsNum,0); 00119 strikeP.resize(pointsNum,0.0F); 00120 bernoulliP.resize(pointsNum,0.0F); 00121 totalErrorRatio = 0; maxMean = 0; minMean = 1; 00122 totEucDist = 0; maxEuc = 0 ; minEuc = 1; 00123 totReg = 0; maxReg = 0; minReg = 1; 00124 zeroCount = 0; 00125 foundTotal = 0.0F; rankTotal = 0.0F; 00126 foundMean = 0.0F; rankMean = 0.0F; 00127 } 00128 00129 void CINNICstatsRun::setStuff() 00130 { 00131 tempImage1c.resize(1,1); 00132 tempImage2.resize(1,1); 00133 salMap.resize(1,1); 00134 point2D = new Point2D<int>; 00135 pointVec.resize(5,*point2D); 00136 pointRankNum.resize(pointsNum,0); 00137 totalErrorRatio = 0; maxMean = 0; minMean = 1; 00138 totEucDist = 0; maxEuc = 0 ; minEuc = 1; 00139 totReg = 0; maxReg = 0; minReg = 1; 00140 zeroCount = 0; 00141 foundTotal = 0.0F; rankTotal = 0.0F; 00142 foundMean = 0.0F; rankMean = 0.0F; 00143 pointsFoundNum.resize(pointsNum,0); 00144 } 00145 00146 void CINNICstatsRun::runStandardStats(readConfig &fileList) 00147 { 00148 //! point2D object 00149 //Point2D<int> *point2D = new Point2D<int>(); 00150 imageCount = fileList.itemCount(); 00151 const char* inCompImage; 00152 00153 //iterate over each image pair 00154 for(int i = 0; fileList.readFileTrue(i); i++) 00155 { 00156 // pair must exist 00157 LINFO("PAIR %d",i); 00158 // get names of images from file list using readConfig 00159 fileList.readFileValueNameC(i); 00160 inCompImage = fileList.readFileValueC(i); 00161 // read the images 00162 tempImage1c = Raster::ReadRGB(fileList.readFileValueNameC(i), RASFMT_PNM); 00163 LINFO("DONE"); 00164 tempImage2 = Raster::ReadGray(fileList.readFileValueC(i), RASFMT_PNM); 00165 LINFO("DONE"); 00166 // Make sure they are good 00167 checkSize(); 00168 00169 // format them 00170 tempImage1cf = tempImage1c; 00171 testImage = luminance(tempImage1cf); 00172 inplaceAttenuateBorders(testImage, edgeAtten); 00173 compImage = tempImage2; 00174 //Raster::VisuFloat(testImage, FLOAT_NORM_0_255, sformat("foo.%d.pgm",i)); 00175 //Raster::VisuFloat(compImage, FLOAT_NORM_0_255, sformat("bar.%d.pgm",i)); 00176 preProcess(); 00177 00178 //Calculate basic stats 00179 testImageVector.assign(testImage.begin(), testImage.end()); 00180 compImageVector.assign(compImage.begin(), compImage.end()); 00181 testMean[i] = Stats.mean(testImageVector); 00182 testStd[i] = Stats.findS(testImageVector,testMean[i]); 00183 LINFO("testMean is %f std %f",testMean[i],testStd[i]); 00184 compMean[i] = Stats.mean(compImageVector); 00185 compStd[i] = Stats.findS(compImageVector,compMean[i]); 00186 LINFO("compMean is %f std %f",compMean[i],compStd[i]); 00187 regression[i] = Stats.rRegression(testImageVector,compImageVector); 00188 00189 00190 // Find the euclidian distance between images 00191 for(int x = 0; x < testImage.getWidth(); x++) 00192 { 00193 for(int y = 0; y < testImage.getHeight(); y++) 00194 { 00195 eucDist[i] += pow((testImage.getVal(x,y) - compImage.getVal(x,y)),2); 00196 } 00197 } 00198 00199 //choped for ease of use 00200 float hold = (1.0F/(testImage.getWidth()*testImage.getHeight())); 00201 eucDist[i] = hold*sqrt(eucDist[i]); 00202 00203 // polarize pixels to either 0 or 255 based on mean 00204 for(int x = 0; x < testImage.getWidth(); x++) 00205 { 00206 for(int y = 0; y < testImage.getHeight(); y++) 00207 { 00208 if(testImage.getVal(x,y) < testMean[i]) 00209 { 00210 testImage.setVal(x,y,0.0F); 00211 } 00212 else 00213 { 00214 testImage.setVal(x,y,254.0F); 00215 } 00216 } 00217 } 00218 00219 //Raster::VisuFloat(compImage, FLOAT_NORM_0_255, sformat("bar3.%d.pgm",i)); 00220 00221 //LEVITY I DEMAND LEVITY 00222 00223 //Raster::VisuFloat(testImage, FLOAT_NORM_0_255, sformat("foo.%d.pgm",i)); 00224 //Raster::VisuFloat(compImage, FLOAT_NORM_0_255, sformat("bar.%d.pgm",i)); 00225 //compImage = rescale(compImage,decSize,decSize); 00226 //testImage = rescale(testImage,decSize,decSize); 00227 //totCount[i] = 0; 00228 //errorCount[i] = 0; 00229 00230 // count for error pixels 00231 for(int x = 0; x < compImage.getWidth(); x++) 00232 { 00233 for(int y = 0; y < compImage.getHeight(); y++) 00234 { 00235 if(testImage.getVal(x,y) > 1) 00236 { 00237 totCount[i]++; 00238 if(compImage.getVal(x,y) < 1) 00239 { 00240 errorCount[i]++; 00241 } 00242 } 00243 } 00244 } 00245 //float avg = totalVal[i]/(compImage.getWidth()*compImage.getHeight()); 00246 if((errorCount[i] != 0) && (totCount[i] != 0)) 00247 { 00248 errorRatio[i] = (float)errorCount[i]/(float)totCount[i]; 00249 } 00250 else 00251 { 00252 errorRatio[i] = 0.0F; 00253 zeroCount++; 00254 } 00255 00256 LINFO("Error count for %s is %d",inCompImage,errorCount[i]); 00257 LINFO("Total count for %s is %d",inCompImage,totCount[i]); 00258 LINFO("Error Ratio is %f",errorRatio[i]); 00259 LINFO("Euclidian distance is %f", eucDist[i]); 00260 LINFO("Regression %f",regression[i]); 00261 //sum stats 00262 totEucDist += eucDist[i]; 00263 totalErrorRatio += errorRatio[i]; 00264 totReg += regression[i]; 00265 //find max and min values 00266 if(eucDist[i] > maxEuc){maxEuc = eucDist[i];} 00267 if(eucDist[i] < minEuc){minEuc = eucDist[i];} 00268 if(errorRatio[i] > maxMean){maxMean = errorRatio[i];} 00269 if(errorRatio[i] < minMean){minMean = errorRatio[i];} 00270 if(regression[i] > maxReg){maxReg = regression[i];} 00271 if(regression[i] < minReg){minReg = regression[i];} 00272 } 00273 meanEucDist = totEucDist/imageCount; 00274 totalMeanError = totalErrorRatio/(imageCount-zeroCount); 00275 meanReg = totReg/imageCount; 00276 00277 stdEucDist = dStats.findS(eucDist, meanEucDist); 00278 totalStdError = Stats.findS(errorRatio, totalMeanError); 00279 stdReg = Stats.findS(regression, meanReg); 00280 00281 LINFO("Total Images Run %d",imageCount); 00282 LINFO("Total Error Ratio %f",totalErrorRatio); 00283 LINFO("Total Mean Error %f :S %f",totalMeanError,totalStdError); 00284 LINFO("Max %f Min %f",maxMean,minMean); 00285 LINFO("Total Mean Euclidian Distance %f :S %f",meanEucDist,stdEucDist); 00286 LINFO("Max %f Min %f",maxEuc,minEuc); 00287 LINFO("Total Mean Regression %f :S %f",meanReg,stdReg); 00288 LINFO("Max %f Min %f",maxReg,minReg); 00289 LINFO("Zero Count %d",zeroCount); 00290 } 00291 00292 void CINNICstatsRun::runPointAndFlood(readConfig &fileList,const char* param) 00293 { 00294 std::ofstream outfile(statsFile.c_str(),std::ios::app); 00295 //while images to be read 00296 LINFO("STARTING Point and Flood"); 00297 int N = 0; 00298 for(int i = 0; fileList.readFileTrue(i); i++) 00299 { 00300 maskImage.resize(compImage.getWidth(),compImage.getHeight(),true); 00301 N = i; 00302 fileList.readFileValueC(i); 00303 fileList.readFileValueNameC(i); 00304 // read the images 00305 tempImage1c = Raster::ReadRGB(fileList.readFileValueNameC(i), RASFMT_PNM); 00306 //LINFO("DONE"); 00307 tempImage2 = Raster::ReadGray(fileList.readFileValueC(i), RASFMT_PNM); 00308 //LINFO("DONE"); 00309 // Make sure they are good 00310 checkSize(); 00311 // format them 00312 tempImage1cf = tempImage1c; 00313 testImage = luminance(tempImage1cf); 00314 inplaceAttenuateBorders(testImage, edgeAtten); 00315 compImage = tempImage2; 00316 salMap.resize(tempImage1c.getWidth(),tempImage1c.getHeight()); 00317 outImageTemplate = compImage; 00318 outImageSource = testImage; 00319 //pixRGB.setGreen(128); 00320 //pixRGB.setBlue(0); 00321 //int setter = 255/pointsNum; 00322 00323 if(preProcessPNF == 1) 00324 preProcess(); 00325 00326 //find salient points, circle them on any outimage, then flood out, repete 00327 pointAndFlood(fileList.readFileValueNameC(i),i,false); 00328 } 00329 00330 for(int n = 0; n < pointsNum; n++) 00331 { 00332 strikeP[n] = (float)candPixels[n]/(float)realPixels[n]; 00333 candPixels[n] = candPixels[n]/N; 00334 realPixels[n] = realPixels[n]/N; 00335 //strikeP[n] = strikeP[n]; 00336 if(n > 0) 00337 { 00338 bernoulliP[n] = (1-bernoulliP[n-1])*strikeP[n] + bernoulliP[n-1]; 00339 } 00340 else 00341 { 00342 bernoulliP[n] = strikeP[n]; 00343 } 00344 } 00345 00346 rankMean = rankTotal/N; 00347 rankSTD = Stats.findS(pointRank,rankMean); 00348 foundMean = foundTotal/N; 00349 foundSTD = Stats.findS(pointsFound,foundMean); 00350 00351 LINFO("#################FINAL#################"); 00352 LINFO("rank mean %f std %f",rankMean,rankSTD); 00353 LINFO("found mean %f std %f",foundMean,foundSTD); 00354 outfile << param << "\t"; 00355 outfile << rankMean << "\t" << rankSTD << "\t"; 00356 outfile << foundMean << "\t" << foundSTD << "\t"; 00357 for(int i = 0; i < pointsNum; i++) 00358 { 00359 LINFO("AT rank %d = %d",i,pointRankNum[i]); 00360 outfile << pointRankNum[i] << "\t"; 00361 } 00362 for(int i = 0; i <= pointsNum; i++) 00363 { 00364 LINFO("FOUND number %d = %d",i,pointsFoundNum[i]); 00365 outfile << pointsFoundNum[i] << "\t"; 00366 } 00367 LINFO("General Stats:"); 00368 for(int i = 0; i < pointsNum; i++) 00369 { 00370 LINFO("[%d] REAL %ld CANDIDATE %ld STRIKE %f BERNOULLI %f",i,realPixels[i] 00371 ,candPixels[i],strikeP[i],bernoulliP[i]); 00372 outfile << realPixels[i] << "\t" << candPixels[i] << "\t" 00373 << strikeP[i] << "\t" << bernoulliP[i] << "\t"; 00374 } 00375 00376 outfile << "\n"; 00377 outfile.close(); 00378 00379 } 00380 00381 void CINNICstatsRun::randomMatch(float *likelyhood, 00382 long *posRegionCount, long *totalCount) 00383 { 00384 long pRC = 0, tC = 0; 00385 float lh; 00386 00387 for(int i = 0; i < compImage.getWidth(); i++) 00388 { 00389 for(int j = 0; j < compImage.getHeight(); j++) 00390 { 00391 if(maskImage.getVal(i,j) < 10.0F) 00392 { 00393 tC++; 00394 if(compImage.getVal(i,j) > rankThresh) 00395 { 00396 pRC++; 00397 } 00398 } 00399 } 00400 } 00401 lh = pRC/tC; 00402 *posRegionCount = pRC; 00403 *totalCount = tC; 00404 *likelyhood = lh; 00405 } 00406 00407 void CINNICstatsRun::preProcess() 00408 { 00409 if(qualityImage == 0) 00410 { 00411 compImage = rescale(compImage,unEvenDec,unEvenDec); 00412 //Raster::VisuFloat(compImage, FLOAT_NORM_0_255, sformat("bar2.%d.pgm",i)); 00413 compImage = lowPass5(compImage); 00414 // create some levity for my bad drawing 00415 00416 for(int x = 0; x < compImage.getWidth(); x++) 00417 { 00418 for(int y = 0; y < compImage.getHeight(); y++) 00419 { 00420 if(compImage.getVal(x,y) < highThresh){compImage.setVal(x,y,255.0F);} 00421 else{compImage.setVal(x,y,0.0F);} 00422 } 00423 } 00424 compImage =\ 00425 rescale(compImage,testImage.getWidth(),testImage.getHeight()); 00426 00427 //compImage = lowPass9(compImage); 00428 //compImage = lowPass5(compImage); 00429 00430 // chop "black" values below chopVal (i.e. 31) 00431 for(int x = 0; x < compImage.getWidth(); x++) 00432 { 00433 for(int y = 0; y < compImage.getHeight(); y++) 00434 { 00435 if(compImage.getVal(x,y) < chopVal){compImage.setVal(x,y,0.0F);} 00436 if(testImage.getVal(x,y) < chopVal){testImage.setVal(x,y,0.0F);} 00437 } 00438 } 00439 } 00440 else 00441 { 00442 for(int x = 0; x < compImage.getWidth(); x++) 00443 { 00444 for(int y = 0; y < compImage.getHeight(); y++) 00445 { 00446 if(compImage.getVal(x,y) < qChop){compImage.setVal(x,y,0.0F);} 00447 } 00448 } 00449 } 00450 } 00451 00452 void CINNICstatsRun::checkSize() 00453 { 00454 if(doResize == 0) 00455 { 00456 ASSERT(tempImage1c.getWidth() == tempImage2.getWidth()); 00457 ASSERT(tempImage1c.getHeight() == tempImage2.getHeight()); 00458 } 00459 else 00460 { 00461 if(tempImage1c.getWidth() != tempImage2.getWidth()) 00462 { 00463 if(tempImage1c.getHeight() != tempImage2.getHeight()) 00464 { 00465 tempImage2 =\ 00466 rescale(tempImage2,tempImage1c.getWidth(),tempImage1c.getHeight()); 00467 } 00468 else 00469 { 00470 ASSERT("skew detected, cannot resize"); 00471 } 00472 } 00473 } 00474 } 00475 00476 PixRGB<float> CINNICstatsRun::colorTable(int i) 00477 { 00478 PixRGB<float> pix; 00479 pix.setRed(0.0F); 00480 pix.setGreen(0.0F); 00481 pix.setBlue(0.0F); 00482 switch(i) 00483 { 00484 case 0: //red 00485 pix.setRed(255.0F); 00486 break; 00487 case 1: //orange 00488 pix.setGreen(128.0F); 00489 pix.setRed(255.0F); 00490 break; 00491 case 2: //yellow 00492 pix.setRed(255.0F); 00493 pix.setGreen(255.0F); 00494 break; 00495 case 3: //green 00496 pix.setGreen(255.0F); 00497 break; 00498 case 4: //blue 00499 pix.setBlue(255.0F); 00500 break; 00501 case 5: //violet(ish) 00502 pix.setRed(255.0F); 00503 pix.setBlue(255.0F); 00504 break; 00505 default: //white 00506 pix.setRed(255.0F); 00507 pix.setGreen(255.0F); 00508 pix.setBlue(255.0F); 00509 } 00510 return pix; 00511 } 00512 00513 void CINNICstatsRun::pointAndFloodImage(Image<float> test_image, 00514 Image<float> sal_map 00515 ,int points,char* filename, 00516 float floodv,float floodt) 00517 { 00518 monoColor = 0; 00519 pointsNum = points; 00520 useDrawDisk = 0; 00521 floodThresh = floodt; 00522 floodVal = floodv; 00523 circRad = 15; 00524 pointAndFloodImage(test_image,sal_map,filename); 00525 } 00526 00527 void CINNICstatsRun::pointAndFloodImage(Image<float> test_image, 00528 Image<float> sal_map 00529 ,char* filename) 00530 { 00531 LINFO("running POINT and FLOOD for %s",filename); 00532 point2D = new Point2D<int>; 00533 testImage = sal_map; 00534 maskImage.resize(sal_map.getWidth(),sal_map.getHeight(),true); 00535 outImageTemplate = test_image; 00536 outImageSource = sal_map; 00537 salMap.resize(sal_map.getWidth(),sal_map.getHeight(),true); 00538 pointAndFlood(filename,0,true); 00539 } 00540 00541 void CINNICstatsRun::pointAndFlood(const char* filename,int i,bool standalone) 00542 { 00543 Image<float> storeImage; 00544 for(int n = 0; n < pointsNum; n++) 00545 { 00546 if(!(standalone)) 00547 { 00548 float strike = 0.0F; 00549 long cand = 0 ,real = 0; 00550 randomMatch(&strike,&cand,&real); 00551 candPixels[n] += cand; 00552 realPixels[n] += real; 00553 } 00554 00555 float maxVal; 00556 findMax(testImage, *point2D,maxVal); 00557 salMap.setVal(*point2D,255.0F); 00558 //LINFO("PixelVal %f",compImage.getVal(*point2D)); 00559 if(!(standalone)) 00560 { 00561 if(compImage.getVal(*point2D) > rankThresh) 00562 { 00563 pointsFound[i]++; //count up 00564 if(pointRank[i] == -1) 00565 { 00566 pointRank[i] = n; //set rank 00567 rankTotal += n; 00568 pointRankNum[(int)pointRank[i]]++; 00569 LINFO("Setting %d as rank %f",i,pointRank[i]); 00570 } 00571 } 00572 } 00573 //pixRGB.setRed(n*setter); 00574 pixRGB = colorTable(n); 00575 if(n > 0) 00576 { 00577 Point2D<int> *oldPoint = new Point2D<int>(ii,jj); 00578 //LINFO("P %d,%d %d,%d",point2D->i,point2D->j,oldPoint->i,oldPoint->j); 00579 if(monoColor != 1) 00580 { 00581 drawArrow(outImageTemplate, *oldPoint,*point2D,pixRGB); 00582 drawArrow(outImageSource, *oldPoint,*point2D,pixRGB); 00583 } 00584 else 00585 { 00586 pixRGB = colorTable(-1); 00587 drawArrow(outImageTemplate, *oldPoint,*point2D,pixRGB,2); 00588 drawArrow(outImageSource, *oldPoint,*point2D,pixRGB,2); 00589 } 00590 } 00591 ii = point2D->i; 00592 jj = point2D->j; 00593 if(monoColor != 1) 00594 { 00595 drawCircle(outImageTemplate, *point2D,circRad,pixRGB); 00596 drawCircle(outImageSource, *point2D,circRad,pixRGB); 00597 } 00598 else 00599 { 00600 //set white (default switch) 00601 pixRGB = colorTable(-1); 00602 drawCircle(outImageTemplate, *point2D,circRad,pixRGB,2); 00603 drawCircle(outImageSource, *point2D,circRad,pixRGB,2); 00604 } 00605 if(useDrawDisk != 1) 00606 { 00607 flood(testImage, storeImage,*point2D,floodThresh,floodVal); 00608 testImage -= storeImage; 00609 } 00610 else 00611 { 00612 drawDisk(testImage, *point2D,diskSize,0.0F); 00613 drawDisk(maskImage, *point2D,diskSize,255.0F); 00614 } 00615 //Raster::VisuFloat(testImage,0,"testimage.pgm"); 00616 } 00617 if(!(standalone)) 00618 { 00619 foundTotal += (int)pointsFound[i]; 00620 pointsFoundNum[(int)pointsFound[i]]++; 00621 LINFO("Number Found %f / %d",pointsFound[i],pointsNum); 00622 } 00623 LINFO("writing %s.salPoint",filename); 00624 00625 Image<PixRGB <byte> > thisBytes = outImageTemplate; 00626 Raster::WriteRGB(thisBytes,sformat("%s.salPoint.ppm",filename)); 00627 thisBytes = outImageSource; 00628 Raster::WriteRGB(thisBytes,sformat("%s,salPointSource.ppm",filename)); 00629 } 00630 00631 float CINNICstatsRun::polatSagi2AFC(Image<float> targetImage, 00632 Image<float> notargetImage) 00633 { 00634 ASSERT(targetImage.getHeight() == notargetImage.getHeight()); 00635 ASSERT(targetImage.getWidth() == notargetImage.getWidth()); 00636 int Xcenter = (targetImage.getWidth()/2)+centerOffset; 00637 int Ycenter = (targetImage.getHeight()/2)+centerOffset; 00638 mu1 = PSError + targetImage.getVal(Xcenter,Ycenter); 00639 mu2 = PSError + notargetImage.getVal(Xcenter,Ycenter); 00640 float sigma1 = sqrt(mu1); 00641 float sigma2 = sqrt(mu2); 00642 return Stats.getErrorGGC_2AFC(mu1,mu2,sigma1,sigma2); 00643 } 00644 00645 float CINNICstatsRun::getMu1() 00646 { 00647 return mu1; 00648 } 00649 00650 float CINNICstatsRun::getMu2() 00651 { 00652 return mu2; 00653 } 00654 00655 // ###################################################################### 00656 /* So things look consistent in everyone's emacs... */ 00657 /* Local Variables: */ 00658 /* indent-tabs-mode: nil */ 00659 /* End: */