test-LabelMeSaliencyJustObj.C

00001 /*! @file ObjRec/test-LabelMeSaliency.C get saliency information from  */
00002 /* the label me data set */
00003 
00004 // //////////////////////////////////////////////////////////////////// //
00005 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2005   //
00006 // by the 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: Lior Elazary <elazary@usc.edu>
00035 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/ObjRec/test-LabelMeSaliencyJustObj.C $
00036 // $Id: test-LabelMeSaliencyJustObj.C 10982 2009-03-05 05:11:22Z itti $
00037 //
00038 
00039 
00040 #include "Component/ModelManager.H"
00041 #include "Image/Image.H"
00042 #include "Image/ImageSet.H"
00043 #include "Image/ShapeOps.H"
00044 #include "Image/DrawOps.H"
00045 #include "Image/FilterOps.H"
00046 #include "Image/ColorOps.H"
00047 #include "Image/Transforms.H"
00048 #include "Image/MathOps.H"
00049 #include "Neuro/StdBrain.H"
00050 #include "Neuro/VisualCortex.H"
00051 #include "Neuro/NeuroOpts.H"
00052 #include "Neuro/SaliencyMap.H"
00053 #include "Media/TestImages.H"
00054 #include "Media/SceneGenerator.H"
00055 #include "Channels/DescriptorVec.H"
00056 #include "Channels/ComplexChannel.H"
00057 #include "GUI/DebugWin.H"
00058 
00059 
00060 
00061 
00062 ModelManager *mgr;
00063 
00064 int main(const int argc, const char **argv)
00065 {
00066 
00067   MYLOGVERB = LOG_INFO;
00068   mgr = new ModelManager("Test LabelMeSaliency");
00069 
00070   //our brain
00071   nub::ref<StdBrain>  brain2(new StdBrain(*mgr));
00072   mgr->addSubComponent(brain2);
00073 
00074 
00075   mgr->exportOptions(MC_RECURSE);
00076   mgr->setOptionValString(&OPT_RawVisualCortexChans, "IOC");
00077   //mgr.setOptionValString(&OPT_RawVisualCortexChans, "I");
00078   //mgr->setOptionValString(&OPT_RawVisualCortexChans, "GNO");
00079   //mgr.setOptionValString(&OPT_RawVisualCortexChans, "N");
00080   //manager.setOptionValString(&OPT_UseOlderVersion, "false");
00081   // set the FOA and fovea radii
00082   mgr->setOptionValString(&OPT_SaliencyMapType, "Fast");
00083   mgr->setOptionValString(&OPT_SMfastInputCoeff, "1");
00084 
00085   mgr->setOptionValString(&OPT_WinnerTakeAllType, "Fast");
00086 
00087   mgr->setModelParamVal("FOAradius", 100, MC_RECURSE);
00088   mgr->setModelParamVal("FoveaRadius", 100, MC_RECURSE);
00089 
00090   mgr->setOptionValString(&OPT_IORtype, "Disc");
00091 
00092   if (mgr->parseCommandLine(
00093         (const int)argc, (const char**)argv, "<path to images>", 1, 1) == false);
00094 
00095   mgr->start();
00096   nub::ref<StdBrain>  brain = dynCastWeak<StdBrain>(mgr->subComponent(0));
00097 
00098  //"/lab/ilab15/tmp/objectsDB/mit/labelMe/05june05_static_indoor",
00099 
00100   TestImages testImages(mgr->getExtraArg(0).c_str(), TestImages::MIT_LABELME);
00101 
00102 
00103   printf("## \"Filename\", \"Size\", \"Number of objects\", \"Obj ID\", \"Size\"\n");
00104 
00105   for(uint scene=0; scene<testImages.getNumScenes(); scene++)
00106   {
00107 
00108     //get the image
00109     LINFO("Get scene %i", scene);
00110     Image<PixRGB<byte> > img = testImages.getScene(scene);
00111     std::string sceneFile = testImages.getSceneFilename(scene);
00112     LINFO("Size %ix%i", img.getWidth(), img.getHeight());
00113 
00114     if (testImages.getNumObj() > 0)  //if we have any labled objects
00115     {
00116       for (uint obj=0; obj<testImages.getNumObj(); obj++)
00117       {
00118         Image<byte> objMask = testImages.getObjMask(obj);
00119         int objSize = -1;
00120         for(int y=0; y<objMask.getHeight(); y++)
00121           for(int x=0; x<objMask.getWidth(); x++)
00122             if (objMask.getVal(x,y) > 0)
00123               objSize++;
00124 
00125        // SHOWIMG(rescale(toRGB(objMask), 255, 255));
00126         std::vector<Point2D<int> > objPoly = testImages.getObjPolygon(obj);
00127         Point2D<int> p1 = objPoly[0];
00128         for(uint i=1; i<objPoly.size(); i++)
00129         {
00130           drawLine(img, p1, objPoly[i], PixRGB<byte>(255, 0, 0), 4);
00131           p1 = objPoly[i];
00132         }
00133         drawLine(img, p1, objPoly[0], PixRGB<byte>(255, 0, 0), 4); //close the polygon
00134 
00135         printf("\"%s\",\"%ix%i\",\"%i\",\"%i\",\"%i\"\n",
00136             sceneFile.c_str(), img.getWidth(), img.getHeight(),
00137             testImages.getNumObj(), obj, objSize);
00138 
00139       }
00140       SHOWIMG(img);
00141 
00142     } else {
00143       printf("##%s has no objects \n", sceneFile.c_str());
00144     }
00145   }
00146 
00147 }
00148 
Generated on Sun May 8 08:05:30 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3