00001 /*!@file Nerdcam/lumin.C NERD CAM program sweet */ 00002 00003 //Nathan Mundhenk 00004 //mundhenk@usc.edu 00005 00006 // //////////////////////////////////////////////////////////////////// // 00007 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2001 by the // 00008 // University of Southern California (USC) and the iLab at USC. // 00009 // See http://iLab.usc.edu for information about this project. // 00010 // //////////////////////////////////////////////////////////////////// // 00011 // Major portions of the iLab Neuromorphic Vision Toolkit are protected // 00012 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency // 00013 // in Visual Environments, and Applications'' by Christof Koch and // 00014 // Laurent Itti, California Institute of Technology, 2001 (patent // 00015 // pending; application number 09/912,225 filed July 23, 2001; see // 00016 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status). // 00017 // //////////////////////////////////////////////////////////////////// // 00018 // This file is part of the iLab Neuromorphic Vision C++ Toolkit. // 00019 // // 00020 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can // 00021 // redistribute it and/or modify it under the terms of the GNU General // 00022 // Public License as published by the Free Software Foundation; either // 00023 // version 2 of the License, or (at your option) any later version. // 00024 // // 00025 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope // 00026 // that it will be useful, but WITHOUT ANY WARRANTY; without even the // 00027 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // 00028 // PURPOSE. See the GNU General Public License for more details. // 00029 // // 00030 // You should have received a copy of the GNU General Public License // 00031 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write // 00032 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, // 00033 // Boston, MA 02111-1307 USA. // 00034 // //////////////////////////////////////////////////////////////////// // 00035 // 00036 // Primary maintainer for this file: T Nathan Mundhenk <mundhenk@usc.edu> 00037 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Nerdcam/lumin.C $ 00038 // $Id: lumin.C 6191 2006-02-01 23:56:12Z rjpeters $ 00039 // 00040 00041 // ############################################################ 00042 // ############################################################ 00043 // ##### ---NERD CAM--- 00044 // ##### Nerd Cam Binary: 00045 // ##### T. Nathan Mundhenk nathan@mundhenk.com 00046 // ############################################################ 00047 // ############################################################ 00048 00049 #include <stdlib.h> 00050 #include <iostream> 00051 #include "Util/log.H" 00052 #include "Image/Image.H" 00053 #include "Image/ColorOps.H" 00054 #include "Raster/Raster.H" 00055 #include "Image/Pixels.H" 00056 00057 //! this is a simple program for determining the average luminocity of an image 00058 00059 //!what file to open 00060 char* filename; 00061 //! image object 00062 Image<PixRGB <float> > image; 00063 //! byte based image 00064 Image<PixRGB <byte> > bimage; 00065 //! float image B/W 00066 Image<float> fimage; 00067 //! luminance of image 00068 float lum; 00069 00070 int main(int argc, char* argv[]) 00071 { 00072 filename = argv[1]; 00073 bimage = Raster::ReadRGB(filename, RASFMT_PNM); 00074 image = bimage; 00075 fimage = luminance(image); 00076 int N = 0; 00077 float sum = 0.0F; 00078 for(int x = 0; x < fimage.getWidth(); x++) 00079 { 00080 for(int y = 0; y < fimage.getHeight(); y++) 00081 { 00082 sum += fimage.getVal(x,y); 00083 N++; 00084 } 00085 } 00086 lum = sum/N; 00087 std::cout << lum << "\n"; 00088 return (int)lum; 00089 } 00090 00091 // ###################################################################### 00092 /* So things look consistent in everyone's emacs... */ 00093 /* Local Variables: */ 00094 /* indent-tabs-mode: nil */ 00095 /* End: */