00001 /*!@file ObjRec/get-obj.C get an object from a mask 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: Lior Elazary <elazary@usc.edu> 00035 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/ObjRec/get-obj.C $ 00036 // $Id: get-obj.C 7063 2006-08-29 18:26:55Z rjpeters $ 00037 // 00038 00039 #include "Component/ModelManager.H" 00040 #include "Image/Image.H" 00041 #include "Image/Pixels.H" 00042 #include "Image/ColorOps.H" 00043 #include "Image/ShapeOps.H" 00044 #include "Image/MathOps.H" 00045 #include "Image/CutPaste.H" 00046 #include "Image/Transforms.H" 00047 #include "Media/FrameSeries.H" 00048 #include "Raster/Raster.H" 00049 #include "Util/log.H" 00050 #include "Util/Timer.H" 00051 #include "Learn/SOFM.H" 00052 #include "GUI/XWinManaged.H" 00053 #include "CMapDemo/SaliencyCMapMT.H" 00054 #include "SIFT/ScaleSpace.H" 00055 #include "SIFT/VisualObject.H" 00056 #include "SIFT/Keypoint.H" 00057 #include "SIFT/VisualObjectDB.H" 00058 #include "Image/FourierEngine.H" 00059 #include "RCBot/Motion/MotionEnergy.H" 00060 00061 #include <signal.h> 00062 00063 00064 #include <sys/types.h> 00065 #include <sys/stat.h> 00066 #include <unistd.h> 00067 00068 #include <sys/types.h> 00069 #include <sys/stat.h> 00070 #include <unistd.h> 00071 00072 00073 00074 00075 int main(const int argc, const char **argv) 00076 { 00077 00078 MYLOGVERB = LOG_INFO; 00079 ModelManager manager("Test SIFT"); 00080 XWinManaged xwin(Dims(704,480), -1, -1, "Get Object"); 00081 00082 if (manager.parseCommandLine( 00083 (const int)argc, (const char**)argv, "<Image> <Mask>", 2, 2) == false); 00084 00085 char filename[255]; 00086 for (int i=0; i<100; i++) 00087 { 00088 00089 sprintf(filename, "%s/RPGData%03d.ppm", manager.getExtraArg(0).c_str(), i); 00090 struct stat statBuf; 00091 if (!stat(filename, &statBuf)) 00092 { 00093 Image<PixRGB<byte> > img = Raster::ReadRGB(filename); 00094 00095 sprintf(filename, "%s/RPGData%03dTarget.pgm", manager.getExtraArg(1).c_str(), i); 00096 Image<PixRGB<byte> > imgMask = Raster::ReadRGB(filename); 00097 00098 00099 Image<PixRGB<byte> >::iterator imgPtr = img.beginw(); 00100 Image<PixRGB<byte> >::const_iterator imgMaskPtr = imgMask.beginw(), 00101 imgMaskStop = imgMask.end(); 00102 00103 while (imgMaskPtr != imgMaskStop) 00104 { 00105 if (imgMaskPtr->p[0] == 0.0f){ 00106 *imgPtr = PixRGB<byte>((byte)0, (byte)0, (byte)0); 00107 } 00108 imgMaskPtr++; imgPtr++; 00109 } 00110 00111 //xwin.drawImage(img); 00112 00113 sprintf(filename, "%s/out%03dTarget.ppm", manager.getExtraArg(1).c_str(), i); 00114 Raster::WriteRGB(img, filename); 00115 00116 } 00117 } 00118 00119 00120 00121 return 0; 00122 00123 }