latest version v1.9 - last update 10 Apr 2010 |
00001 /* 00002 * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 00003 * Lehrstuhl fuer Technische Informatik, RWTH-Aachen, Germany 00004 * 00005 * This file is part of the LTI-Computer Vision Library (LTI-Lib) 00006 * 00007 * The LTI-Lib is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public License (LGPL) 00009 * as published by the Free Software Foundation; either version 2.1 of 00010 * the License, or (at your option) any later version. 00011 * 00012 * The LTI-Lib is distributed in the hope that it will be 00013 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 00014 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with the LTI-Lib; see the file LICENSE. If 00019 * not, write to the Free Software Foundation, Inc., 59 Temple Place - 00020 * Suite 330, Boston, MA 02111-1307, USA. 00021 */ 00022 00023 00024 /*---------------------------------------------------------------- 00025 * project ....: LTI Digital Image/Signal Processing Library 00026 * file .......: ltiGaussianPyramid.h 00027 * authors ....: Pablo Alvarado 00028 * organization: LTI, RWTH Aachen 00029 * creation ...: 30.10.00 00030 * revisions ..: $Id: ltiGaussianPyramid.h,v 1.3 2006/02/08 11:10:28 ltilib Exp $ 00031 */ 00032 00033 #ifndef _LTI_GAUSSIAN_PYRAMID_H_ 00034 #define _LTI_GAUSSIAN_PYRAMID_H_ 00035 00036 #include "ltiPyramid.h" 00037 #include "ltiTypes.h" 00038 00039 namespace lti { 00040 /** 00041 * GaussianPyramid class. 00042 * 00043 * This class implements the gaussian pyramids as described in 00044 * Greenspan et.at. "Overcomplete Steerable Pyramid Filters and 00045 * Rotation Invariance", Proc. of the IEEE Conf. on Computer Visiona 00046 * and Pattern Recognition, Seattle, 1994 00047 * 00048 * It allows an easy manipulation of the different resolutions. 00049 * 00050 * See method generate() to an detailed explanation. 00051 * 00052 * The template type T is the type of the elements in the pyramid. 00053 * 00054 * Example: 00055 * 00056 * \code 00057 * 00058 * channel chnl; 00059 * // initialize channel or load it from an image... 00060 * 00061 * lti::gaussianPyramid<lti::channel> thePyramid(4); // four levels 00062 * thePyramid.generate(chnl); // generate a pyramid for the given channel 00063 * 00064 * \endcode 00065 */ 00066 template <class T> 00067 class gaussianPyramid : public pyramid<T> { 00068 public: 00069 00070 /** 00071 * create a gaussian pyramid with the given number of resolutions 00072 * @param resolutions the number of resolutions that the pyramid can hold 00073 * (default 0: an empty pyramid will be created) 00074 * @param upsampleWithGaussian a gaussian kernel will be used to 00075 * upsample the images. If false a squared 00076 * kernel will be used. 00077 * 00078 * @param gaussianSize the size of the gaussian kernel (default 3) 00079 * @param variance the variance of the gaussian kernel (default -1, meaning 00080 * that the variance should be calculated as described in 00081 * the lti::gaussKernel1D<T>) 00082 */ 00083 gaussianPyramid(const int& resolutions = 0, 00084 const int& gaussianSize = 3, 00085 const double& variance = -1, 00086 const bool& upsampleWithGaussian = true); 00087 00088 /** 00089 * create this gaussianPyramid as a copy of another gaussianPyramid 00090 * @param other the gaussianPyramid to be copied. 00091 */ 00092 gaussianPyramid(const gaussianPyramid& other); 00093 00094 /** 00095 * destructor 00096 */ 00097 virtual ~gaussianPyramid(); 00098 00099 /** 00100 * return the size and variance of the used gaussian kernel 00101 */ 00102 void getKernelParameters(int& size, 00103 double& variance, 00104 bool& gaussian) const; 00105 00106 /** 00107 * set the kernel parameters 00108 * 00109 * @param size the size of the kernel 00110 * @param variance the variance for the gaussian kernel. A negative 00111 * value will force the default variance of a gaussian 00112 * kernel with size <code>size</code>. 00113 * @param gaussian specify if for the channel upsampling a gaussian or 00114 * a rectangular kernel should be used. 00115 */ 00116 void setKernelParameters(const int& size, 00117 const double& variance=-1, 00118 const bool& gaussian = true); 00119 00120 /** 00121 * returns the name of this class: "gaussianPyramid" 00122 */ 00123 const char* getTypeName() const {return "gaussianPyramid";}; 00124 00125 /** 00126 * assigment operator. 00127 * copy the contents of <code>other</code> in this %object. 00128 * @param other the source gaussianPyramid to be copied. 00129 * @return a reference to this object 00130 */ 00131 gaussianPyramid<T>& copy(const gaussianPyramid<T>& other); 00132 00133 /** 00134 * create a clone of this gaussianPyramid 00135 * @return a pointer to a copy of this gaussianPyramid 00136 */ 00137 virtual mathObject* clone() const; 00138 00139 /** 00140 * generate the gaussian pyramid of the given object. 00141 * 00142 * The pyramid will contain the number of resolutions specified in 00143 * the construction or in the resize() method. The resolution "0" 00144 * will correspond the the original channel, and the resolution 00145 * i+1 is always a factor 2 smaller than the resolution i. 00146 */ 00147 void generate(const T& src); 00148 00149 /** 00150 * generate the gaussian pyramid of the given object. 00151 * 00152 * The pyramid will contain the number of resolutions specified 00153 * by theResolutions. 00154 * The resolution "0" will correspond the the original channel, 00155 * and the resolution i+1 is always a factor 2 smaller than 00156 * the resolution i. 00157 */ 00158 void generate(const T& src,const int& theResolutions); 00159 00160 /** 00161 * generate the gaussian pyramid of the given object. Proceed, until 00162 * given limit.x or limit.y is reached. smallest resolution will be > limit. 00163 * 00164 * The resolution "0" corresponds to the original channel, and the resolution 00165 * i+1 is always a factor 2 smaller than the resolution i. 00166 */ 00167 void generate(const T& src, const lti::point& limit); 00168 00169 /** 00170 * reconstructs the resolution with index i from a second resolution j. 00171 * If i>j, the object at(i) will be returned, otherwise the corresponding 00172 * upsampling will be done with the kernel type specified in the 00173 * construction 00174 * 00175 * @param i the resolution to be reconstructed 00176 * @param fromJ the resolution from which the data is to be taken. 00177 * @param result the resulting object 00178 * @return a reference to the result object. 00179 */ 00180 T& reconstruct(const int& i, const int& fromJ, T& result) const; 00181 00182 /** 00183 * reconstructs the resolution with index i from a second 00184 * resolution j. 00185 * If i>j, the object the same pyramid will be 00186 * returned, otherwise the corresponding upsampling will be done 00187 * with the kernel type specified in the construction 00188 * A pyramid with the same original size will be returned, where only 00189 * the elements between i and fromJ will be initialized. 00190 * 00191 * @param i the resolution to be reconstructed 00192 * @param fromJ the resolution from which the data is to be taken. 00193 * @param result the resulting pyramid. 00194 * @return a reference to the result pyramid 00195 */ 00196 pyramid<T>& reconstruct(const int& i, const int& fromJ, 00197 pyramid<T>& result) const; 00198 00199 protected: 00200 00201 /** 00202 * kernel size 00203 */ 00204 int kernelSize; 00205 00206 /** 00207 * kernel variance 00208 */ 00209 double kernelVariance; 00210 00211 /** 00212 * specify if the upsampling kernel is gaussian (true) or 00213 * rectangular(false) 00214 */ 00215 bool gaussian; 00216 }; 00217 00218 } // namespace lti 00219 00220 #include "ltiGaussianPyramid_template.h" 00221 00222 #endif