00001 /*!@file AppPsycho/createBarStimuli.C program to generate bar stimuli for pulvinar experiment */ 00002 00003 // //////////////////////////////////////////////////////////////////// // 00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2005 // 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: Farhan Baluch <fbaluch at usc dot edu> 00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/AppPsycho/createBarStimuli.C $ 00035 // $Id: createBarStimuli.C 10794 2009-02-08 06:21:09Z itti $ 00036 // 00037 00038 #ifndef APPNEURO_CREATEBARSTIMULI_C_DEFINED 00039 #define APPNEURO_CREATEBARSTIMULI_C_DEFINED 00040 00041 #include "Component/ModelManager.H" 00042 #include "GUI/XWinManaged.H" 00043 #include "Image/Image.H" 00044 #include "Image/Pixels.H" 00045 #include "Image/ShapeOps.H" // for rescale() 00046 #include "Image/FilterOps.H" //for correlation(); 00047 #include "Image/CutPaste.H" 00048 #include "Image/DrawOps.H" 00049 #include "Image/MathOps.H" 00050 #include "Image/ColorOps.H" 00051 #include "Neuro/getSaliency.H" 00052 #include "Raster/Raster.H" 00053 #include "Util/log.H" 00054 #include "Psycho/EyeTrace.H" 00055 #include "Image/MathOps.H" 00056 #include "Util/StringConversions.H" 00057 #include <fstream> 00058 #include <iostream> 00059 #include <stdio.h> 00060 #include <stdlib.h> 00061 00062 //this code will generate bar stimuli for pulvinar experiment. 00063 00064 int main(int argc, char** argv) 00065 { 00066 ModelManager manager("create stimuli for pulvinar experiment"); 00067 00068 nub::ref<GetSaliency> saliency(new GetSaliency(manager)); 00069 manager.addSubComponent(saliency); 00070 00071 if (manager.parseCommandLine(argc, argv, "<orientation1> <orientation2>", 2, 2) == false) 00072 return -1; 00073 manager.start(); 00074 00075 00076 Dims dims(700,700); 00077 Image<PixRGB<byte> > inputImg(600,600,NO_INIT); 00078 00079 Image<PixRGB<byte> >::iterator aptr=inputImg.beginw(); 00080 00081 while(aptr!= inputImg.end()) 00082 *aptr++ = PixRGB<byte>(127.0,127.0,127.0); 00083 00084 int numBars=8; 00085 int hSpacing=50,vSpacing=50,beginX=100,beginY = 100; 00086 double or1, or2; 00087 or1 = atof(manager.getExtraArg(0).c_str()); 00088 or2 = atof(manager.getExtraArg(1).c_str()); 00089 00090 for(int i=0; i<numBars;i++) 00091 for(int j=0;j<numBars;j++) 00092 { 00093 if(i==2 && j==3) 00094 drawLine(inputImg, Point2D<int>(beginX+j*hSpacing,beginY+i*vSpacing),or1*M_PI/180,25.0,PixRGB<byte>(255.0,255.0,0.0),2); 00095 else if (i==5 && j==6) 00096 drawLine(inputImg, Point2D<int>(beginX+j*hSpacing,beginY+i*vSpacing),or2*M_PI/180,25.0,PixRGB<byte>(255.0,255.0,0.0),2); 00097 else 00098 drawLine(inputImg, Point2D<int>(beginX+j*hSpacing,beginY+i*vSpacing),20*M_PI/180,25.0,PixRGB<byte>(255.0,255.0,0.0),2); 00099 00100 } 00101 00102 00103 00104 const int numSalientSpotsTr = saliency->compute(inputImg, SimTime::SECS(1)); 00105 00106 std::string temp ="found" + convertToString(numSalientSpotsTr) + " salient spots"; 00107 00108 LINFO("%s",temp.c_str()); 00109 00110 const Image<float> OrigSalmap = saliency->getSalmap(); 00111 // writeText(OrigSalMap,Point2D<int>(5,5),temp.c_str()); 00112 00113 00114 XWinManaged *imgWin; 00115 CloseButtonListener wList; 00116 imgWin = new XWinManaged(dims,0,0, manager.getExtraArg(0).c_str()); 00117 wList.add(imgWin); 00118 imgWin->drawImage(inputImg); 00119 00120 char filename[255],salname[255]; 00121 sprintf(filename,"/lab/farhan/research/pulvinar/sampleDisp.png"); 00122 sprintf(salname,"/lab/farhan/research/pulvinar/sampleDispSal.png"); 00123 00124 Raster::WriteRGB(inputImg,filename); 00125 Raster::WriteFloat(rescale(OrigSalmap,inputImg.getDims()),FLOAT_NORM_0_255,salname); 00126 00127 Raster::waitForKey(); 00128 00129 manager.stop(); 00130 00131 return 0; 00132 } 00133 00134 // ###################################################################### 00135 /* So things look consistent in everyone's emacs... */ 00136 /* Local Variables: */ 00137 /* mode: c++ */ 00138 /* indent-tabs-mode: nil */ 00139 /* End: */ 00140 00141 #endif // APPPSYCHO_CREATEBARSTIMULI_C_DEFINED