00001 /*!@file MBARI/test-BitObject.C test program for the class BitObject 00002 */ 00003 // //////////////////////////////////////////////////////////////////// // 00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2002 // 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: Dirk Walther <walther@caltech.edu> 00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/MBARI/test-BitObject.C $ 00035 // $Id: test-BitObject.C 9412 2008-03-10 23:10:15Z farhan $ 00036 // 00037 00038 #include "Image/ColorOps.H" 00039 #include "Image/Image.H" 00040 #include "Image/Pixels.H" 00041 #include "MBARI/BitObject.H" 00042 #include "Raster/Raster.H" 00043 #include "Util/StringConversions.H" 00044 #include "Util/Types.H" 00045 #include "Util/log.H" 00046 00047 int main(const int argc, const char** argv) 00048 { 00049 if (argc < 2) LFATAL("usage: %s image.ppm [i,j]",argv[0]); 00050 00051 Image<byte> img = luminance(Raster::ReadRGB(argv[1])); 00052 00053 LINFO("Image %s loaded.", argv[1]); 00054 00055 BitObject bobj; 00056 00057 if (argc >= 3) 00058 { 00059 Point2D<int> loc = fromStr<Point2D<int> >(argv[2]); 00060 LINFO("location = %s",toStr(loc).c_str()); 00061 bobj.reset(img, loc); 00062 LINFO("BitObject created."); 00063 if (!bobj.isValid()) 00064 { 00065 LINFO("No Object found at location %s.",toStr(loc).c_str()); 00066 return 0; 00067 } 00068 00069 } 00070 else 00071 { 00072 bobj.reset(img); 00073 LINFO("BitObject created."); 00074 if (!bobj.isValid()) 00075 { 00076 LINFO("No Object found in image %s.",argv[1]); 00077 return 0; 00078 } 00079 } 00080 00081 LINFO("BoundingBox = %s",toStr(bobj.getBoundingBox()).c_str()); 00082 LINFO("Centroid = %s",toStr(bobj.getCentroid()).c_str()); 00083 LINFO("Area = %d",bobj.getArea()); 00084 float uxx, uyy, uxy; 00085 bobj.getSecondMoments(uxx,uyy,uxy); 00086 LINFO("uxx = %g; uyy = %g; uxy = %g",uxx,uyy,uxy); 00087 LINFO("major Axis = %g", bobj.getMajorAxis()); 00088 LINFO("minor Axis = %g", bobj.getMinorAxis()); 00089 LINFO("elongation = %g", bobj.getElongation()); 00090 LINFO("orientation angle = %g", bobj.getOriAngle()); 00091 } 00092 00093 00094 // ###################################################################### 00095 /* So things look consistent in everyone's emacs... */ 00096 /* Local Variables: */ 00097 /* indent-tabs-mode: nil */ 00098 /* End: */