00001 /*!@file SpaceVariant/FovealTransformModule.C space variant transformation module */ 00002 00003 // //////////////////////////////////////////////////////////////////// // 00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2003 // 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: David J. Berg <dberg@usc.edu> 00034 // $HeadURL: svn://isvn.usc.edu:/software/invt/trunk/saliency/src/SpaceVariant/FovealTransformModule.C $ 00035 00036 #include "SpaceVariant/FovealTransformModule.H" 00037 #include "SpaceVariant/SpaceVariantTransforms.H" 00038 #include "SpaceVariant/SpaceVariantOpts.H" 00039 #include "Channels/ChannelOpts.H" 00040 #include "Neuro/NeuroOpts.H" 00041 #include "Image/CutPaste.H" 00042 00043 // ###################################################################### 00044 // ###################################################################### 00045 // ########## FovealTransformModule implementation 00046 // ###################################################################### 00047 // ###################################################################### 00048 FovealTransformModule::FovealTransformModule(OptionManager& mgr, const std::string& descrName, const std::string& tagName) : 00049 SpaceVariantModule(mgr, descrName, tagName), 00050 itsSvScale(&OPT_SpaceVariantScale, this), 00051 itsSvFovea(&OPT_SpaceVariantFoveaSize, this), 00052 itsSvSfac(&OPT_SpaceVariantSfac, this), 00053 itsSvBeta(&OPT_SpaceVariantBeta, this), 00054 itsSvGain(&OPT_SpaceVariantGain, this), 00055 itsSvExponent(&OPT_SpaceVariantExponent, this), 00056 itsSvOffset(&OPT_SpaceVariantOffset, this), 00057 itsFoveaCutoff(&OPT_SpaceVariantFovCut, this), 00058 itsSvDims(&OPT_SpaceVariantDims, this), 00059 itsPPD(&OPT_PixelsPerDegree, this), 00060 itsLevelSpec(&OPT_LevelSpec, this) 00061 { } 00062 00063 // ###################################################################### 00064 FovealTransformModule::~FovealTransformModule() 00065 { } 00066 00067 // ###################################################################### 00068 void FovealTransformModule::clear(const Dims& inp_dims) 00069 { 00070 //one to transform retinal images 00071 FovealTransform* t = new FovealTransform(); 00072 t->setup(inp_dims.w(), inp_dims.h(), 00073 itsSvDims.getVal().w(), itsSvDims.getVal().h(), 00074 itsSvFovea.getVal(), itsSvBeta.getVal(), 00075 itsSvGain.getVal(), itsSvExponent.getVal(), itsSvOffset.getVal(), 00076 itsPPD.getVal().ppdx(), itsPPD.getVal().ppdy(), 00077 FovealTransform::toScaleType(itsSvScale.getVal()), 00078 itsSvSfac.getVal(), itsFoveaCutoff.getVal()); 00079 itsTransform.reset(t); 00080 00081 //this one gets used downstream to invert map level images 00082 const int w = inp_dims.w() >> itsLevelSpec.getVal().mapLevel(); 00083 const int h = inp_dims.h() >> itsLevelSpec.getVal().mapLevel(); 00084 const int svw = itsSvDims.getVal().w()*2 >> itsLevelSpec.getVal().mapLevel(); 00085 const int svh = itsSvDims.getVal().h()/2 >> itsLevelSpec.getVal().mapLevel(); 00086 00087 FovealTransform* t1 = new FovealTransform(); 00088 t1->setup(w, h, svw/2, svh*2, 00089 itsSvFovea.getVal(), itsSvBeta.getVal(), 00090 itsSvGain.getVal(), itsSvExponent.getVal(), itsSvOffset.getVal(), 00091 itsPPD.getVal().ppdx(), itsPPD.getVal().ppdy(), 00092 FovealTransform::toScaleType(itsSvScale.getVal()), itsSvSfac.getVal(), 0.0); 00093 itsMapTransform.reset(t1); 00094 00095 if ((w % 2 != 0) || (h % 2 != 0)) 00096 LDEBUG("After pyramid operations, the input image is ideally divisible by two for " 00097 "space variant image processing. Try increasing the input image size or " 00098 "altering the pyramid depth or output level."); 00099 00100 if (svh % 2 != 0) 00101 LDEBUG("After pyramid operations, the transformed is ideally divisible by two for " 00102 "space variant image processing. Try increasing the space variant height (angles) or " 00103 "altering the pyramid depth or output level."); 00104 00105 LINFO("FovealTransform transform configured."); 00106 } 00107 00108 // ###################################################################### 00109 template <class T_or_RGB> 00110 void FovealTransformModule::getFoveaPeriphery(const Image<T_or_RGB>& ret_image, 00111 Image<T_or_RGB>& fovea, Image<T_or_RGB>& periphery) 00112 { 00113 ::getFoveaPeriphery(static_cast<FovealTransform&>(*itsTransform), ret_image, fovea, periphery); 00114 } 00115 00116 // ###################################################################### 00117 Dims FovealTransformModule::getSVDims() const 00118 { 00119 return itsSvDims.getVal(); 00120 } 00121 00122 #define INST_CLASS FovealTransformModule:: 00123 #include "inst/SpaceVariant/FovealTransformModule.I" 00124 // ###################################################################### 00125 /* So things look consistent in everyone's emacs... */ 00126 /* Local Variables: */ 00127 /* indent-tabs-mode: nil */ 00128 /* End: */