latest version v1.9 - last update 10 Apr 2010 |
00001 /* 00002 * Copyright (C) 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 .......: ltiLaplacianPyramid.h 00027 * authors ....: Pablo Alvarado 00028 * organization: LTI, RWTH Aachen 00029 * creation ...: 19.03.01 00030 * revisions ..: $Id: ltiLaplacianPyramid.h,v 1.4 2006/02/08 11:22:01 ltilib Exp $ 00031 */ 00032 00033 #ifndef _LTI_LAPLACIAN_PYRAMID_H_ 00034 #define _LTI_LAPLACIAN_PYRAMID_H_ 00035 00036 #include "ltiPyramid.h" 00037 #include "ltiGaussianPyramid.h" 00038 #include "ltiTypes.h" 00039 00040 namespace lti { 00041 /** 00042 * LaplacianPyramid class. 00043 * 00044 * This class implements the Laplacian pyramids as described in 00045 * Greenspan et.at. "Overcomplete Steerable Pyramid Filters and 00046 * Rotation Invariance", Proc. of the IEEE Conf. on Computer Vision 00047 * and Pattern Recognition, Seattle, 1994 00048 * 00049 * Each level corresponds to a difference of Gaussians, where the 00050 * level distance is always one octave. 00051 * 00052 * It allows an easy manipulation of the different resolutions. 00053 * 00054 * See method generate() to an detailed explanation 00055 * 00056 */ 00057 template <class T> 00058 class laplacianPyramid : public pyramid<T> { 00059 public: 00060 00061 /** 00062 * create a laplacian pyramid with the given number of resolutions 00063 * @param resolutions the number of resolutions that the pyramid can hold 00064 * (default 0: an empty pyramid will be created) 00065 * @param gaussianSize the size of the laplacian kernel (default 3) 00066 * @param variance the variance of the laplacian kernel (default -1, 00067 * meaning that the variance should be calculated as 00068 * described in the lti::gaussKernel1D<T>) 00069 */ 00070 laplacianPyramid(const int& resolutions = 0, 00071 const int& gaussianSize = 3, 00072 const double& variance = -1); 00073 00074 /** 00075 * create this laplacianPyramid as a copy of another laplacianPyramid 00076 * @param other the laplacianPyramid to be copied. 00077 */ 00078 laplacianPyramid(const laplacianPyramid& other); 00079 00080 /** 00081 * destructor 00082 */ 00083 virtual ~laplacianPyramid(); 00084 00085 /** 00086 * return the size and variance of the used gaussian kernel 00087 */ 00088 void getKernelParameters(int& size, 00089 double& variance) const; 00090 00091 /** 00092 * set the kernel parameters 00093 * 00094 * @param size the size of the kernel 00095 * @param variance the variance for the laplacian kernel. A negative 00096 * value will force the default variance of a laplacian 00097 * kernel with size <code>size</code>. 00098 */ 00099 void setKernelParameters(const int& size, 00100 const double& variance=-1); 00101 00102 /** 00103 * returns the name of this class: "laplacianPyramid" 00104 */ 00105 const char* getTypeName() const {return "laplacianPyramid";}; 00106 00107 /** 00108 * assigment operator. 00109 * copy the contents of <code>other</code> in this %object. 00110 * @param other the source laplacianPyramid to be copied. 00111 * @return a reference to this object 00112 */ 00113 laplacianPyramid<T>& copy(const laplacianPyramid<T>& other); 00114 00115 /** 00116 * create a clone of this laplacianPyramid 00117 * @return a pointer to a copy of this laplacianPyramid 00118 */ 00119 virtual mathObject* clone() const; 00120 00121 /** 00122 * generate the laplacian pyramid of the given object. 00123 * 00124 * The pyramid will contain the number of resolutions specified in 00125 * the construction or in the resize() method. The resolution "0" 00126 * will correspond the the original channel, and the resolution 00127 * i+1 is always a factor 2 smaller than the resolution i. 00128 */ 00129 void generate(const T& src); 00130 00131 /** 00132 * generate the laplacian pyramid of the given object. 00133 * 00134 * The pyramid will contain the number of resolutions specified 00135 * by theResolutions. 00136 * The resolution "0" will correspond the the original channel, 00137 * and the resolution i+1 is always a factor 2 smaller than 00138 * the resolution i. 00139 */ 00140 void generate(const T& src,const int& theResolutions); 00141 00142 /** 00143 * generate the laplacian pyramid of the given object. Proceed, 00144 * until given limit.x or limit.y is reached. smallest resolution 00145 * will be > limit. 00146 * 00147 * The resolution "0" corresponds to the original channel, and the 00148 * resolution i+1 is always a factor 2 smaller than the resolution 00149 * i. 00150 */ 00151 void generate(const T& src, const lti::point& limit); 00152 00153 00154 /** 00155 * generate the laplacian pyramid using the given gaussian pyramid 00156 */ 00157 void generate(const gaussianPyramid<T>& src); 00158 00159 00160 /** 00161 * reconstructs the resolution with index i. 00162 * 00163 * @param i the resolution to be reconstructed 00164 * @param result the resulting object 00165 * @return a reference to the result object. 00166 */ 00167 T& reconstruct(const int& i, T& result) const; 00168 00169 /** 00170 * reconstructs the resolution with index i. 00171 * 00172 * All partial reconstructions will be stored at the given 00173 * gaussian pyramid. 00174 * 00175 * @param i the resolution to be reconstructed 00176 * @param result the resulting pyramid. 00177 * @return a reference to the result pyramid 00178 */ 00179 pyramid<T>& reconstruct(const int& i, pyramid<T>& result) const; 00180 00181 protected: 00182 00183 /** 00184 * kernel size 00185 */ 00186 int kernelSize; 00187 00188 /** 00189 * kernel variance 00190 */ 00191 double kernelVariance; 00192 00193 /** 00194 * subtract b from a, and leave the result in c, which will have the size 00195 * of a, even if the sizes of a and b differ. 00196 */ 00197 void subtract(const T& a,const T& b, T& c) const; 00198 00199 /** 00200 * add a and b, and leave the result in c, which will have the size 00201 * of a, even if the sizes of a and b differ. 00202 */ 00203 void add(const T& a,const T& b, T& c) const; 00204 00205 }; 00206 00207 } // namespace lti 00208 00209 #include "ltiLaplacianPyramid_template.h" 00210 00211 #endif