00001 /*!@file CINNIC/CINNICtest.C Tests the CINNIC neuron */ 00002 00003 // //////////////////////////////////////////////////////////////////// // 00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2001 by the // 00005 // 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: T Nathan Mundhenk <mundhenk@usc.edu> 00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/CINNIC/CINNICtest.C $ 00035 // $Id: CINNICtest.C 6410 2006-04-01 22:12:24Z rjpeters $ 00036 // 00037 00038 // ############################################################ 00039 // ############################################################ 00040 // ##### ---CINNIC--- 00041 // ##### Contour Integration: 00042 // ##### T. Nathan Mundhenk nathan@mundhenk.com 00043 // ############################################################ 00044 // ############################################################ 00045 00046 //This is the start of the execution path for the CINNIC test alg. 00047 #include "CINNIC/CINNIC.H" 00048 #include "CINNIC/cascadeHold.H" 00049 #include "Util/log.H" 00050 #include "Util/readConfig.H" 00051 #include <fstream> 00052 #include <iostream> 00053 #include <sstream> 00054 #include <stdlib.h> 00055 #include <sys/types.h> 00056 #include <time.h> 00057 00058 //! Create a CINNIC neuron, use float 00059 ContourNeuronCreate<float> CINNICreate; 00060 //! Standard CINNIC test object 00061 CINNIC skeptic; 00062 //! pointer to command line argument stream 00063 std::istream* argInput; 00064 //! This is the configFile name 00065 const char* configFile; 00066 //! This is the configFile object 00067 readConfig configIn(25); 00068 //! This is the main function for CINNIC 00069 /*! to use this you must have a config file called contour.conf 00070 you should run this file by running it from src3 and executing it 00071 as such "../bin/CINNICtest ../image_in/imagefile outputname" where 00072 imagefile is a ppm file (do not include extention) and outputname 00073 is the name you would like attached to all the output files. 00074 */ 00075 00076 int main(int argc, char* argv[]) 00077 { 00078 time_t t1,t2; 00079 (void) time(&t1); 00080 00081 if(argc > 3) 00082 { 00083 configFile = argv[3]; 00084 } 00085 else 00086 { 00087 configFile = "contour.conf"; 00088 } 00089 skeptic.filename = "noName"; 00090 LINFO("LOADING CONFIG FILE"); 00091 configIn.openFile(configFile); 00092 /*for(int i = 0; configIn.readFileTrue(i); i++) 00093 { 00094 std::cout << configIn.readFileValueName(i) << ":" << configIn.readFileValueF(i) << "\n"; 00095 }*/ 00096 LINFO("Starting CINNIC test\n"); 00097 CINNICreate.CreateNeuron(configIn); 00098 LINFO("CINNIC template Neuron copied, ready for use"); 00099 int choice = 0; 00100 00101 if(argc > 2) 00102 { 00103 skeptic.savefilename = argv[2]; 00104 } 00105 else 00106 { 00107 skeptic.savefilename = "noname"; 00108 } 00109 if(argc > 1) //command line argument 00110 { 00111 LINFO("argc %d", argc); 00112 argInput = new std::istringstream(argv[1]); 00113 skeptic.Ninput = Image<byte>(100,100, NO_INIT); 00114 skeptic.Ninput = Raster::ReadGray(argv[1], RASFMT_PNM); 00115 00116 skeptic.filename = argv[1]; 00117 LINFO("Image Loaded"); 00118 skeptic.RunSimpleImage(CINNICreate,skeptic.Ninput,configIn); 00119 LINFO("done!"); 00120 } 00121 else //no command line specified 00122 { 00123 std::ofstream outfile("kernel_set.dat",std::ios::out); 00124 choice = 0; 00125 while((choice < 9) && (choice > -1)) 00126 { 00127 std::cout << "\n"; 00128 std::cout << "iLab Global Dominanation Project (c) 2001\n"; 00129 std::cout << "1 - Alpha Angle\n" 00130 << "2 - Beta Angle\n" 00131 << "3 - Distance\n" 00132 << "4 - Polarity\n" 00133 << "5 - Alpha/Beta Combo\n" 00134 << "6 - Alpha/Beta/Distance Combo\n" 00135 << "7 - coLinearity\n" 00136 << "8 - Visual ABD Combo\n" 00137 << "9 - QUIT\n\n" 00138 << "Choice: "; 00139 std::cin >> choice; 00140 if(choice == 8){skeptic.viewNeuronTemplate(CINNICreate,configIn);} 00141 if(choice < 8) 00142 { 00143 for (int i = 0; i < AnglesUsed; i++) 00144 { 00145 std::cout << "\n"; 00146 outfile << "\n"; 00147 for (int j = 0; j < AnglesUsed; j++) 00148 { 00149 std::cout << "\n\nNeuron:" << NeuralAngles[i] << " Other:" << NeuralAngles[j]; 00150 for (int l = YSize; l >= 0; --l) 00151 { 00152 std::cout << "\n"; 00153 outfile << "\n"; 00154 for (int k = 0; k <= XSize; k++) 00155 { 00156 if(choice == 1) 00157 { 00158 printf("%f ",CINNICreate.FourDNeuralMap[i][j][k][l].ang2); 00159 outfile << CINNICreate.FourDNeuralMap[i][j][k][l].ang2 << "\t"; 00160 } 00161 if(choice == 2) 00162 { 00163 printf("%f ",CINNICreate.FourDNeuralMap[i][j][k][l].ang); 00164 outfile << CINNICreate.FourDNeuralMap[i][j][k][l].ang << "\t"; 00165 } 00166 if(choice == 3) 00167 { 00168 printf("%f ",CINNICreate.FourDNeuralMap[i][j][k][l].dis); 00169 outfile << CINNICreate.FourDNeuralMap[i][j][k][l].dis << "\t"; 00170 } 00171 if(choice == 4) 00172 { 00173 if(CINNICreate.FourDNeuralMap[i][j][k][l].pol) 00174 { 00175 std::cout << "1"; 00176 } 00177 else 00178 { 00179 std::cout << "0"; 00180 } 00181 std::cout << ":"; 00182 if(CINNICreate.FourDNeuralMap[i][j][k][l].sender) 00183 { 00184 std::cout << "1"; 00185 } 00186 else 00187 { 00188 std::cout << "0"; 00189 } 00190 std::cout << " "; 00191 } 00192 if(choice == 5) 00193 { 00194 printf("%f ",CINNICreate.FourDNeuralMap[i][j][k][l].angAB); 00195 outfile << CINNICreate.FourDNeuralMap[i][j][k][l].angAB << "\t"; 00196 } 00197 if(choice == 6) 00198 { 00199 printf("%f ",CINNICreate.FourDNeuralMap[i][j][k][l].angABD); 00200 outfile << CINNICreate.FourDNeuralMap[i][j][k][l].angABD << "\t"; 00201 } 00202 if(choice == 7) 00203 { 00204 if(CINNICreate.FourDNeuralMap[i][j][k][l].coLinear) 00205 { 00206 std::cout << "1"; 00207 } 00208 else 00209 { 00210 std::cout << "0"; 00211 } 00212 std::cout << " "; 00213 } 00214 } 00215 } 00216 } 00217 } 00218 } 00219 } 00220 } 00221 (void) time(&t2); 00222 long int tl = (long int) t2-t1; 00223 printf("\n*************************************\n"); 00224 printf("Time to execute, %ld seconds\n",tl); 00225 printf("*************************************\n\n"); 00226 00227 00228 00229 return 1; 00230 } 00231 00232 // ###################################################################### 00233 /* So things look consistent in everyone's emacs... */ 00234 /* Local Variables: */ 00235 /* indent-tabs-mode: nil */ 00236 /* End: */