app-Omni.C

Go to the documentation of this file.
00001 /*!@file AppMedia/app-Omni.C  Omnidirectional lens distortion correction tool
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: T. Nathan Mundhenk <mundhenk@usc.edu>
00035 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/AppMedia/app-Omni.C $
00036 // $Id: app-Omni.C 6410 2006-04-01 22:12:24Z rjpeters $
00037 //
00038 
00039 #include "Image/Image.H"
00040 #include "Image/OmniOps.H"
00041 #include "Image/Pixels.H"
00042 #include "Raster/Raster.H"
00043 #include "Util/log.H"
00044 #include "Util/readConfig.H"
00045 
00046 // ############################################################
00047 // ############################################################
00048 // ##### ---OMNI---
00049 // ##### OMNI DIRECTIONAL CORRECTION TOOL:
00050 // ##### T. Nathan Mundhenk nathan@mundhenk.com
00051 // ############################################################
00052 // ############################################################
00053 
00054 //! omni directional correction tool
00055 template<class T> class Omni
00056 {
00057 public:
00058   //!Omni correction object constructor
00059   Omni();
00060   //!Omni correction object destructor
00061   ~Omni();
00062   //! Run omni correction on an Image, return a new Image
00063   /*! This method will call both Omni corrections for
00064     general and special correction on an Image. The two
00065     methods can be found in Image.H as omniCorrectGen and
00066     omniCorrectSP. If a pinhole image is used omniCorrectSP
00067     may be skipped.
00068     @param image This is the image to be corrected of type Image
00069     @param config This is the config file for processing of type readConfig
00070   */
00071   Image<T> run(const Image<T>& image, readConfig &config);
00072 private:
00073   int centerDetect,radiusDetect,centerX,centerY,radX,radY,radAdg,nebRadius;
00074   float r,h,k;
00075   Image<T> correctImage;
00076 };
00077 
00078 //! This is the configFile name
00079 const char* configFile;
00080 //! This is the configFile object
00081 readConfig configIn(25);
00082 //! This is an Image object for RGB images
00083 Image< PixRGB<byte> > image;
00084 //! This is an Image object for RGB images
00085 Image< PixRGB<byte> > newImage;
00086 //! This is an Image object for RGB images
00087 Omni< PixRGB<byte> > omni;
00088 /*! This is the main funcion for omni directional correction.
00089   Its main purpose is to call the omni-directional methods
00090   in class Omni. Call from src2. You must supply Omni.conf
00091   as a config file. The command line argument is
00092   "../bin/Omni ../image_in/imagefile". Images centers and
00093   radius can be calculated by Omni, or specified in the
00094   Omni.conf file.
00095 */
00096 
00097 
00098 int main(int argc, char* argv[])
00099 {
00100   configFile = "Omni.conf";
00101   configIn.openFile(configFile);
00102   if(argc > 1)
00103   {
00104     newImage.resize(1,1);
00105     image = Raster::ReadRGB(argv[1], RASFMT_PNM);
00106     Raster::VisuRGB(image,"infile.ppm");
00107     newImage = omni.run(image,configIn);
00108     Raster::VisuRGB(newImage,"outfile.ppm");
00109   }
00110   return 0;
00111 }
00112 
00113 template <class T>
00114 Omni<T>::Omni()
00115 {
00116 }
00117 
00118 template <class T>
00119 Omni<T>::~Omni()
00120 {
00121 }
00122 
00123 //! Run omni directional equations on an Image with parameters from readConfig
00124 template <class T>
00125 Image<T> Omni<T>::run(const Image<T>& image, readConfig &config)
00126 {
00127   nebRadius = (int)config.getItemValueF("centerDetect");
00128   centerDetect = (int)config.getItemValueF("centerDetect");
00129   LINFO("centerDetect %d", centerDetect);
00130   radiusDetect = (int)config.getItemValueF("radiusDetect");
00131   LINFO("radiusDetect %d", radiusDetect);
00132   r = config.getItemValueF("r");
00133   LINFO("r %f",r);
00134   h = config.getItemValueF("h");
00135   LINFO("h %f",h);
00136   k = config.getItemValueF("k");
00137   LINFO("k %f",k);
00138   if(centerDetect == 1)
00139   {
00140     centerX = (image.getWidth()/2);
00141     centerY = (image.getWidth()/2);
00142   }
00143   else
00144   {
00145     centerX = (int)config.getItemValueF("centerX");
00146     centerY = (int)config.getItemValueF("centerY");
00147   }
00148 
00149   if(radiusDetect == 1)
00150   {
00151     radAdg = (int)config.getItemValueF("radAdg");
00152     radX = (image.getWidth()/2);
00153     radY = radX;
00154   }
00155   else
00156   {
00157     radX = (int)config.getItemValueF("radX");
00158     radY = (int)config.getItemValueF("radY");
00159   }
00160   LINFO("radX %d",radX);
00161   LINFO("radY %d",radY);
00162   LINFO("centerX %d",centerX);
00163   LINFO("centerY %d",centerX);
00164 
00165   LINFO("CORRECTING IMAGE GENERAL");
00166   Image<T> correctedImage = omniCorrectGen(image,radX,radY,
00167                                            centerX,centerY,radAdg);
00168   Raster::VisuRGB(correctedImage,"Omni_general.ppm");
00169   return omniDenebulize(correctedImage, nebRadius);
00170 }
00171 
00172 // ######################################################################
00173 /* So things look consistent in everyone's emacs... */
00174 /* Local Variables: */
00175 /* indent-tabs-mode: nil */
00176 /* End: */
Generated on Sun May 8 08:04:11 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3