test-hmax4.C

Go to the documentation of this file.
00001 /*!@file HMAX/test-hmax4.C Test Hmax class and compare to original code */
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: Daesu Chung <dchung@usc.edu>
00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/HMAX/test-hmax4.C $
00035 // $Id: test-hmax4.C 6191 2006-02-01 23:56:12Z rjpeters $
00036 //
00037 
00038 #include "GUI/XWindow.H"
00039 #include "HMAX/Hmax.H"
00040 #include "Image/Image.H"
00041 #include "Image/MathOps.H"
00042 #include "Image/Transforms.H"
00043 #include "Raster/Raster.H"
00044 #include "Util/Types.H"
00045 #include "Util/log.H"
00046 
00047 #include <iostream>
00048 #include <unistd.h>
00049 
00050 // number of orientations to use in Hmax
00051 #define NORI 4
00052 
00053 int main(const int argc, const char **argv)
00054 {
00055   if (argc != 2)
00056     { std::cerr<<"USAGE: test-hmax <file>"<<std::endl; exit(1); }
00057 
00058   // get an Hmax object:
00059   std::vector<int> scss(5);
00060   scss[0] = 0; scss[1] = 2; scss[2] = 5; scss[3] = 8; scss[4] = 12;
00061   std::vector<int> spss(4);
00062   spss[0] = 4; spss[1] = 6; spss[2] = 9; spss[3] = 12;
00063   Hmax hmax(NORI, spss, scss);
00064 
00065   // read the image:
00066   Image<byte> input = Raster::ReadGray(argv[1], RASFMT_PNM);
00067 
00068   // let's get an Xwindow:
00069   XWindow xwin(input.getDims());
00070 
00071   // pass image through Hmax model:
00072   Image<float> inputf = input;   // convert image to floats
00073   Image<float> c2resp = hmax.getC2(inputf);
00074   float mi, ma; getMinMax(c2resp, mi, ma);
00075   LINFO("min=%f max=%f", mi, ma);
00076 
00077   // display C2 response in an X window:
00078   c2resp = scaleBlock(c2resp, input.getDims());
00079   inplaceNormalize(c2resp, 0.0F, 255.0F);
00080   Image<byte> result = c2resp; // convert to byte
00081   xwin.drawImage(result);
00082 
00083   sleep(10);
00084   return 0;
00085 }
00086 
00087 // ######################################################################
00088 /* So things look consistent in everyone's emacs... */
00089 /* Local Variables: */
00090 /* indent-tabs-mode: nil */
00091 /* End: */
Generated on Sun May 8 08:40:41 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3