runStimMaker.C

Go to the documentation of this file.
00001 /*!@file AppPsycho/runStimMaker.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/AppPsycho/runStimMaker.C $
00036 // $Id: runStimMaker.C 14376 2011-01-11 02:44:34Z pez $
00037 //
00038 
00039 #ifndef RUN_STIM_MAKER_C_DEFINED
00040 #define RUN_STIM_MAKER_C_DEFINED
00041 
00042 #include "Psycho/StimMaker.H"
00043 #define STIM_DEMO_MODE false
00044 #define STIM_MAKE_SURPRISE_SET true
00045 
00046 using std::string;
00047 
00048 //**********************************************************************
00049 
00050 int main(const int argc, const char **argv)
00051 {
00052   if(STIM_DEMO_MODE)
00053   {
00054     LINFO("RUNNING IN DEMO MODE");
00055     StimMakerParam stim;
00056     StimMaker      maker(512,512,120,SM_COLOR_BLACK);
00057 
00058     LINFO("RUNNING FIRST DEMO");
00059     stim.setDemoParams1();
00060     maker.SM_makeUniformStim(stim);
00061     std::vector<Image<PixRGB<float> > > stim1 = maker.SM_getStim();
00062     std::vector<Image<PixRGB<float> > > gt1   = maker.SM_getGroundTruth();
00063 
00064     LINFO("RUNNING SECOND DEMO");
00065     maker.SM_init(SM_COLOR_BLACK);
00066     stim.setDemoParams2();
00067     maker.SM_makeUniformStim(stim);
00068     std::vector<Image<PixRGB<float> > > stim2 = maker.SM_getStim();
00069     std::vector<Image<PixRGB<float> > > gt2   = maker.SM_getGroundTruth();
00070 
00071     LINFO("RUNNING THIRD DEMO");
00072     maker.SM_init(SM_COLOR_BLACK);
00073     stim.setDemoParams3();
00074     maker.SM_makeUniformStim(stim);
00075     std::vector<Image<PixRGB<float> > > stim3 = maker.SM_getStim();
00076     std::vector<Image<PixRGB<float> > > gt3   = maker.SM_getGroundTruth();
00077 
00078     LINFO("RUNNING FOURTH DEMO");
00079     maker.SM_init(SM_COLOR_BLACK);
00080     stim.setDemoParams4();
00081     maker.SM_makeUniformStim(stim);
00082     std::vector<Image<PixRGB<float> > > stim4 = maker.SM_getStim();
00083     std::vector<Image<PixRGB<float> > > gt4   = maker.SM_getGroundTruth();
00084 
00085     LINFO("WRITING OUT FILES");
00086     for(uint i = 0; i < stim1.size(); i++)
00087     {
00088       const uint frameNumber = i;
00089 
00090       char c[100];
00091       string a, Myname;
00092       string b = ".";
00093       if(frameNumber < 10)
00094         sprintf(c,"00000%d",frameNumber);
00095       else if(frameNumber < 100)
00096         sprintf(c,"0000%d",frameNumber);
00097       else if(frameNumber < 1000)
00098         sprintf(c,"000%d",frameNumber);
00099       else if(frameNumber < 10000)
00100         sprintf(c,"00%d",frameNumber);
00101       else if(frameNumber < 100000)
00102         sprintf(c,"0%d",frameNumber);
00103       else
00104         sprintf(c,"%d",frameNumber);
00105 
00106       a      = "frame.set1";
00107       Myname = a + b + c;
00108 
00109       Raster::WriteRGB(stim1[i],Myname,RASFMT_PNM);
00110 
00111 
00112       a      = "frame.set2";
00113       Myname = a + b + c;
00114       Raster::WriteRGB(stim2[i],Myname,RASFMT_PNM);
00115       a      = "frame.set3";
00116       Myname = a + b + c;
00117       Raster::WriteRGB(stim3[i],Myname,RASFMT_PNM);
00118       a      = "frame.set4";
00119       Myname = a + b + c;
00120       Raster::WriteRGB(stim4[i],Myname,RASFMT_PNM);
00121 
00122 
00123       a      = "frame.GT1";
00124       Myname = a + b + c;
00125 
00126       Raster::WriteRGB(gt1[i],Myname,RASFMT_PNM);
00127 
00128 
00129       a      = "frame.GT2";
00130       Myname = a + b + c;
00131       Raster::WriteRGB(gt2[i],Myname,RASFMT_PNM);
00132       a      = "frame.GT3";
00133       Myname = a + b + c;
00134 
00135       Raster::WriteRGB(gt3[i],Myname,RASFMT_PNM);
00136       a      = "frame.GT4";
00137       Myname = a + b + c;
00138       Raster::WriteRGB(gt4[i],Myname,RASFMT_PNM);
00139 
00140 
00141     }
00142   }
00143   if(STIM_MAKE_SURPRISE_SET)
00144   {
00145     LINFO("RUNNING SURPRISE SET");
00146     StimMakerParam stim;
00147     StimMaker      maker(256,256,120,SM_COLOR_BLACK);
00148 
00149     stim.setBasicParams1();
00150 
00151     std::vector<unsigned char> distColor(2,0);
00152     distColor[0]    = SM_COLOR_BLUE;
00153     distColor[1]    = SM_COLOR_YELLOW;
00154     std::vector<unsigned char> shape(2,0);
00155     shape[0]        = SM_STIM_CROSS;
00156     shape[1]        = SM_STIM_DISK;
00157     std::vector<float>         distOri(2,0.0F);
00158     distOri[0]      = M_PI/4.0F;
00159     distOri[1]      = 0.0F;
00160     std::vector<float>         jitter(2,0.0F);
00161     jitter[0]       = 0.0F;
00162     jitter[1]       = 0.2F;
00163 
00164     stim.SMP_targetColor                  = SM_COLOR_BLUE;
00165     stim.SMP_targetOri                    = 0.0F;
00166     stim.SMP_shapeOrientationJitter       = 0.0F;
00167     stim.SMP_shapePositionJitterStatic    = 0.2F;
00168     stim.SMP_shapeOrientationJitterStatic = 0.2F;
00169 
00170 
00171     for(unsigned char p = 0; p < 2; p++)
00172     {
00173       LINFO(">SHAPE %d - %d",p,shape[p]);
00174       stim.SMP_distShape   = shape[p];
00175       stim.SMP_targetShape = shape[p];
00176       for(unsigned char i = 0; i < 3; i++)
00177       {
00178         LINFO(">> DIST RATE %d",i);
00179         stim.SMP_distRate = i;
00180         for(unsigned char j = 0; j < 3; j++)
00181         {
00182           LINFO(">>> TARGET RATE %d",j);
00183           stim.SMP_targetRate = j;
00184           for(unsigned char k = 0; k < 3; k++)
00185           {
00186             LINFO(">>>> DIST STATE %d",k);
00187             stim.SMP_distState = k;
00188             for(unsigned char l = 0; l < 3; l++)
00189             {
00190               LINFO(">>>>> TARGET STATE %d",l);
00191               stim.SMP_targetState = l;
00192               for(unsigned char n = 0; n < 2; n++)
00193               {
00194                 LINFO(">>>>>> JITTER %d - %f",n,jitter[n]);
00195                 stim.SMP_shapePositionJitter = jitter[n];
00196                 for(unsigned char o = 0; o < 2; o++)
00197                 {
00198                   LINFO(">>>>>>> DIST COLOR %d - %d",o,distColor[o]);
00199                   stim.SMP_distColor = distColor[o];
00200                   float ori    = 0.0F;
00201                   for(unsigned char m = 0; m < 2; m++)
00202                   {
00203 
00204                     if(stim.SMP_distShape == SM_STIM_CROSS)
00205                     {
00206                       ori    = distOri[m];
00207                     }
00208                     else
00209                     {
00210                       ori    = 0.0F;
00211                     }
00212                     LINFO(">>>>>>>> DIST ORI %d - %f",m,ori);
00213                     if((m < 1) || (stim.SMP_distShape == SM_STIM_CROSS))
00214                     {
00215                       LINFO("STIM OK");
00216                       stim.SMP_distOri = ori;
00217                       maker.SM_makeUniformStim(stim);
00218                       std::vector<Image<PixRGB<float> > > stim
00219                         = maker.SM_getStim();
00220                       std::vector<Image<PixRGB<float> > > gt
00221                         = maker.SM_getGroundTruth();
00222 
00223                       for(uint x = 0; x < stim.size(); x++)
00224                       {
00225                         const uint frameNumber = x;
00226 
00227                         char c[100];
00228                         char d[100];
00229                         string a, Myname;
00230                         string b = ".";
00231                         if(frameNumber < 10)
00232                           sprintf(c,"00000%d",frameNumber);
00233                         else if(frameNumber < 100)
00234                           sprintf(c,"0000%d",frameNumber);
00235                         else if(frameNumber < 1000)
00236                           sprintf(c,"000%d",frameNumber);
00237                         else if(frameNumber < 10000)
00238                           sprintf(c,"00%d",frameNumber);
00239                         else if(frameNumber < 100000)
00240                           sprintf(c,"0%d",frameNumber);
00241                         else
00242                           sprintf(c,"%d",frameNumber);
00243 
00244                         sprintf(d,"%d.%d.%d.%d.%d.%d.%d.%d",p,i,j,k,l,n,o,m);
00245 
00246                         a      = "surprise.set";
00247                         Myname = a + b + d + b + c;
00248                         Raster::WriteRGB(stim[x],Myname,RASFMT_PNG);
00249                         a      = "surprise.GT4";
00250                         Myname = a + b + d + b + c;
00251                         Raster::WriteRGB(gt[x],Myname,RASFMT_PNG);
00252                       }
00253                       maker.SM_init(SM_COLOR_BLACK);
00254                     }
00255                   }
00256                 }
00257               }
00258             }
00259           }
00260         }
00261       }
00262     }
00263   }
00264   LINFO("DONE");
00265 }
00266 
00267 #endif
Generated on Sun May 8 08:04:21 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3