app-analyze-stim.C

Go to the documentation of this file.
00001 /*!@file AppMedia/app-analyze-stim.C make different kind of visual test stimuli
00002 */
00003 
00004 // //////////////////////////////////////////////////////////////////// //
00005 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2001 by the //
00006 // University of Southern California (USC) and the iLab at USC.         //
00007 // See http://iLab.usc.edu for information about this project.          //
00008 // //////////////////////////////////////////////////////////////////// //
00009 // Major portions of the iLab Neuromorphic Vision Toolkit are protected //
00010 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency //
00011 // in Visual Environments, and Applications'' by Christof Koch and      //
00012 // Laurent Itti, California Institute of Technology, 2001 (patent       //
00013 // pending; application number 09/912,225 filed July 23, 2001; see      //
00014 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status).     //
00015 // //////////////////////////////////////////////////////////////////// //
00016 // This file is part of the iLab Neuromorphic Vision C++ Toolkit.       //
00017 //                                                                      //
00018 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can   //
00019 // redistribute it and/or modify it under the terms of the GNU General  //
00020 // Public License as published by the Free Software Foundation; either  //
00021 // version 2 of the License, or (at your option) any later version.     //
00022 //                                                                      //
00023 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope  //
00024 // that it will be useful, but WITHOUT ANY WARRANTY; without even the   //
00025 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
00026 // PURPOSE.  See the GNU General Public License for more details.       //
00027 //                                                                      //
00028 // You should have received a copy of the GNU General Public License    //
00029 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write   //
00030 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,   //
00031 // Boston, MA 02111-1307 USA.                                           //
00032 // //////////////////////////////////////////////////////////////////// //
00033 //
00034 // Primary maintainer for this file: T. Nathan Mundhenk <mundhenk@usc.edu>
00035 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/AppMedia/app-analyze-stim.C $
00036 // $Id: app-analyze-stim.C 6795 2006-06-29 20:45:32Z rjpeters $
00037 
00038 #include <cfloat>
00039 #include <fstream>
00040 #include <iostream>
00041 #include <math.h>
00042 #include <string>
00043 #include <vector>
00044 
00045 #include "Util/log.H"
00046 #include "Raster/Raster.H"
00047 #include "Image/Image.H"
00048 #include "Psycho/StimAnalyzer.H"
00049 
00050 using namespace std;
00051 
00052 int main(const int argc, const char **argv)
00053 {
00054   if(argc < 4)
00055   {
00056     std::cerr << "image-prefix      - prefix#.png for salmap\n";
00057     std::cerr << "gt-prefix         - prefix#.png for ground truth images\n";
00058     std::cerr << "output-stats-file - file to append frame stats to\n";
00059     std::cerr << "output-stats-file - file to append total stats to\n";
00060     std::cerr << "frames            - number of frames to run\n";
00061     LFATAL("Usage: app-analyze-stim image-prefix gt-prefix output-stats-file output-stats-file frames");
00062   }
00063   const string inFilePrefix   = argv[1];
00064   const string inFileGTPrefix = argv[2];
00065   const string outStatsFileF  = argv[3];
00066   const string outStatsFileT  = argv[4];
00067   const unsigned int frames   = atoi(argv[5]);
00068 
00069   const string dot            = ".";
00070   const string type           = "png";
00071 
00072   StimAnalyzer SA(frames,1);
00073 
00074   for(unsigned int i = 0; i < frames; i++)
00075   {
00076     char c[100];
00077     if(i < 10)
00078       sprintf(c,"00000%d",i);
00079     else if(i < 100)
00080       sprintf(c,"0000%d",i);
00081     else if(i < 1000)
00082       sprintf(c,"000%d",i);
00083     else if(i < 10000)
00084       sprintf(c,"00%d",i);
00085     else if(i < 100000)
00086       sprintf(c,"0%d",i);
00087     else
00088       sprintf(c,"%d",i);
00089 
00090     const string imageName = inFilePrefix   + c + dot + type;
00091     const string gtName    = inFileGTPrefix + c + dot + type;
00092 
00093     const Image<byte> inImage       = Raster::ReadGray(imageName);
00094     const Image<PixRGB<byte> > inGT = Raster::ReadRGB(gtName);
00095 
00096     const Image<float> finImage       = inImage;
00097     const Image<PixRGB<float> > finGT = inGT;
00098 
00099     SA.SAinputImages(finImage,finGT,i,0);
00100     SA.SAcompImages();
00101   }
00102 
00103   SA.SAfinalStats();
00104   SA.SAdumpFrameStats(inFilePrefix,outStatsFileF,false);
00105   SA.SAdumpConditionStats(inFilePrefix,outStatsFileT,false);
00106 }
00107 
00108 
00109 
00110 
00111 
00112 
00113 
Generated on Sun May 8 08:40:07 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3