latest version v1.9 - last update 10 Apr 2010 |
00001 /* 00002 * Copyright (C) 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 .......: ltiSecondDerivativeKernels.h 00027 * authors ....: Peter Doerfler 00028 * organization: LTI, RWTH Aachen 00029 * creation ...: 18.03.2004 00030 * revisions ..: $Id: ltiSecondDerivativeKernels.h,v 1.3 2006/02/08 11:48:57 ltilib Exp $ 00031 */ 00032 00033 /** 00034 * \file ltiSecondDerivativeKernels.h Defines several linear kernels 00035 * for the computation of the second derivative. Each kernel type has 00036 * three classes for derivatives xx, xy, and yy. They are derived 00037 * from kernels defined in ltiGradientKernels.h. Examples are the Ando 00038 * kernels, and other classical ones like Sobel, Prewitt, etc. 00039 */ 00040 00041 #ifndef _LTI_SECONDDERIVATIVEKERNELS_H_ 00042 #define _LTI_SECONDDERIVATIVEKERNELS_H_ 00043 00044 #include "ltiLinearKernels.h" 00045 #include <limits> 00046 00047 namespace lti { 00048 /** 00049 * Two-dimensional separable filter kernels for the second 00050 * derivative approximation. They are found by convolution of two 00051 * optimal gradient kernels as introduced by Ando. For more details 00052 * see lti::gradientKernelX. 00053 * 00054 * Kernel sizes 5x5, 7x7 and 9x9 are available. 00055 * 00056 * This object will correspond to the second derivative with respect 00057 * to the x-Axis. For the y-Axis just exchange the 1D filter 00058 * kernels, or use the lti::andoKernelYY. 00059 * 00060 * The template parameter T should be the same as the value_type of 00061 * the matrix or channel to be filtered (channel::value_type, double, etc.) 00062 * 00063 * It is recomended to use this kernels with floating point matrices 00064 * or channels, due to precision aspects. 00065 * 00066 * @ingroup gLinearFilters 00067 */ 00068 template<class T> 00069 class andoKernelXX : public sepKernel<T> { 00070 public: 00071 /** 00072 * constructor 00073 * @param size is the dimension of the one dimensional part (i.e. the 00074 * filter kern is a size x size kernel!) 00075 * The valid values are 5, 7 or 9. If an invalid value is 00076 * given, an empty kernel will be created. 00077 */ 00078 andoKernelXX(const int& size = 5); 00079 00080 /** 00081 * initialize this kernel with the specified values 00082 * @param size size of the kernel in one dimension 00083 */ 00084 void generate(const int& size); 00085 }; 00086 00087 /** 00088 * Two-dimensional separable filter kernels for the second 00089 * derivative approximation. They are found by convolution of two 00090 * optimal gradient kernels as introduced by Ando. For more details 00091 * see lti::gradientKernelX. 00092 * 00093 * Kernel sizes 5x5, 7x7 and 9x9 are available. 00094 * 00095 * This object will correspond to the second derivative in xy direction. 00096 * 00097 * The template parameter T should be the same as the value_type of 00098 * the matrix or channel to be filtered (channel::value_type, double, etc.) 00099 * 00100 * It is recomended to use this kernels with floating point matrices 00101 * or channels, due to precision aspects. 00102 * 00103 * @ingroup gLinearFilters 00104 */ 00105 template<class T> 00106 class andoKernelXY : public sepKernel<T> { 00107 public: 00108 /** 00109 * constructor 00110 * @param size is the dimension of the one dimensional part (i.e. the 00111 * filter kern is a size x size kernel!) 00112 * The valid values are 5, 7 or 9. If an invalid value is 00113 * given, an empty kernel will be created. 00114 */ 00115 andoKernelXY(const int& size = 5); 00116 00117 /** 00118 * initialize this kernel with the specified values 00119 * @param size size of the kernel in one dimension 00120 */ 00121 void generate(const int& size); 00122 }; 00123 00124 /** 00125 * Two-dimensional separable filter kernels for the second 00126 * derivative approximation. They are found by convolution of two 00127 * optimal gradient kernels as introduced by Ando. For more details 00128 * see lti::gradientKernelY. 00129 * 00130 * Kernel sizes 5x5, 7x7 and 9x9 are available. 00131 * 00132 * This object will correspond to the second derivative with respect 00133 * to the y-Axis. For the x-Axis just exchange the 1D filter 00134 * kernels, or use the lti::andoKernelXX. 00135 * 00136 * The template parameter T should be the same as the value_type of 00137 * the matrix or channel to be filtered (channel::value_type, double, etc.) 00138 * 00139 * It is recomended to use this kernels with floating point matrices 00140 * or channels, due to precision aspects. 00141 * 00142 * @ingroup gLinearFilters 00143 */ 00144 template<class T> 00145 class andoKernelYY : public sepKernel<T> { 00146 public: 00147 /** 00148 * constructor 00149 * @param size is the dimension of the one dimensional part (i.e. the 00150 * filter kern is a size x size kernel!) 00151 * The valid values are 5, 7 or 9. If an invalid value is 00152 * given, an empty kernel will be created. 00153 */ 00154 andoKernelYY(const int& size = 5); 00155 00156 /** 00157 * initialize this kernel with the specified values 00158 * @param size size of the kernel in one dimension 00159 */ 00160 void generate(const int& size); 00161 }; 00162 00163 00164 /** 00165 * Sobel Kernel XX 00166 * 00167 * Define as a 5x5 separable kernel: 00168 * 00169 * \code 00170 * 1 0 -2 0 1 00171 * 4 0 -8 0 4 00172 * 8 0 -12 0 8 00173 * 4 0 -8 0 4 00174 * 1 0 -2 0 1 00175 * \endcode 00176 */ 00177 template<class T> 00178 class sobelKernelXX : public sepKernel<T> { 00179 public: 00180 /** 00181 * Constructor 00182 * 00183 * @param normalized if true, the kernel will be normalized so that 00184 * in the low-pass axis (perpendicular to the derivative axis) 00185 * the mean value remains the same, i.e. the kernel will be 00186 * multiplied by 1/16. 00187 */ 00188 sobelKernelXX(const bool normalized = false); 00189 }; 00190 00191 /** 00192 * Sobel Kernel XY 00193 * 00194 * Defined as a 5x5 separable kernel: 00195 * 00196 * \code 00197 * 1 2 0 -2 -1 00198 * 2 4 0 -4 -2 00199 * 0 0 0 0 0 00200 * -2 -4 0 4 2 00201 * -1 -2 0 2 1 00202 * \endcode 00203 */ 00204 template<class T> 00205 class sobelKernelXY : public sepKernel<T> { 00206 public: 00207 /** 00208 * Constructor 00209 * 00210 * This kernel does not need to be normalized. 00211 */ 00212 sobelKernelXY(); 00213 }; 00214 00215 /** 00216 * Sobel Kernel YY 00217 * 00218 * Define as a 5x5 separable kernel: 00219 * 00220 * \code 00221 * 1 4 8 4 1 00222 * 0 0 0 0 0 00223 * -2 -8 -12 -8 -2 00224 * 0 0 0 0 0 00225 * 1 4 8 4 1 00226 * \endcode 00227 */ 00228 template<class T> 00229 class sobelKernelYY : public sepKernel<T> { 00230 public: 00231 /** 00232 * Constructor 00233 * 00234 * @param normalized if true, the kernel will be normalized so that 00235 * in the low-pass axis (perpendicular to the derivative axis) 00236 * the mean value remains the same, i.e. the kernel will be 00237 * multiplied by 1/16. 00238 */ 00239 sobelKernelYY(const bool normalized = false); 00240 }; 00241 00242 /** 00243 * Prewitt Kernel XX 00244 * 00245 * Define as a 5x5 separable kernel: 00246 * 00247 * \code 00248 * 1 0 -2 0 1 00249 * 2 0 -4 0 2 00250 * 3 0 -6 0 3 00251 * 2 0 -4 0 2 00252 * 1 0 -2 0 1 00253 * \endcode 00254 */ 00255 template<class T> 00256 class prewittKernelXX : public sepKernel<T> { 00257 public: 00258 /** 00259 * Constructor 00260 * 00261 * @param normalized if true, the kernel will be normalized so that 00262 * in the low-pass axis (perpendicular to the derivative axis) 00263 * the mean value remains the same, i.e. the kernel will be 00264 * multiplied by 1/9. 00265 */ 00266 prewittKernelXX(const bool normalized = false); 00267 }; 00268 00269 /** 00270 * Prewitt Kernel XY 00271 * 00272 * Defined as a 5x5 separable kernel: 00273 * 00274 * \code 00275 * 1 1 0 -1 -1 00276 * 1 1 0 -1 -1 00277 * 0 0 0 0 0 00278 * -1 -1 0 1 1 00279 * -1 -1 0 1 1 00280 * \endcode 00281 */ 00282 template<class T> 00283 class prewittKernelXY : public sepKernel<T> { 00284 public: 00285 /** 00286 * Constructor 00287 * 00288 * Normalization is not necessary for this kernel. 00289 */ 00290 prewittKernelXY(); 00291 }; 00292 00293 /** 00294 * Prewitt Kernel YY 00295 * 00296 * Define as a 5x5 separable kernel: 00297 * 00298 * \code 00299 * 1 2 3 2 1 00300 * 0 0 0 0 0 00301 * -2 -4 -6 -4 -2 00302 * 0 0 0 0 0 00303 * 1 2 3 2 1 00304 * \endcode 00305 */ 00306 template<class T> 00307 class prewittKernelYY : public sepKernel<T> { 00308 public: 00309 /** 00310 * Constructor 00311 * 00312 * @param normalized if true, the kernel will be normalized so that 00313 * in the low-pass axis (perpendicular to the derivative axis) 00314 * the mean value remains the same, i.e. the kernel will be 00315 * multiplied by 1/9. 00316 */ 00317 prewittKernelYY(const bool normalized = false); 00318 }; 00319 00320 /** 00321 * Harris Kernel XX 00322 * 00323 * Define as a 1x9 separable kernel: 00324 * 00325 * \code 00326 * 4 4 1 -4 -10 -4 1 4 4 00327 * \endcode 00328 */ 00329 template<class T> 00330 class harrisKernelXX : public sepKernel<T> { 00331 public: 00332 /** 00333 * Constructor 00334 * 00335 * There is no normalization option as with other second derivative kernels 00336 * since the harris kernel does not have a low-pass component. 00337 */ 00338 harrisKernelXX(); 00339 }; 00340 00341 /** 00342 * Harris Kernel XY 00343 * 00344 * Define as a 5x5 separable kernel: 00345 * 00346 * \code 00347 * 4 2 0 -2 -4 00348 * 2 1 0 -1 -2 00349 * 0 0 0 0 0 00350 * -2 -1 0 1 2 00351 * -4 -2 0 2 4 00352 * \endcode 00353 */ 00354 template<class T> 00355 class harrisKernelXY : public sepKernel<T> { 00356 public: 00357 /** 00358 * Constructor 00359 * 00360 * There is no normalization option as with other second derivative kernels 00361 * since the harris kernel does not have a low-pass component. 00362 */ 00363 harrisKernelXY(); 00364 }; 00365 00366 /** 00367 * Harris Kernel YY 00368 * 00369 * Define as a 9x1 separable kernel: 00370 * 00371 * \code 00372 * [4 4 1 -4 -10 -4 1 4 4] transposed 00373 * \endcode 00374 */ 00375 template<class T> 00376 class harrisKernelYY : public sepKernel<T> { 00377 public: 00378 /** 00379 * Constructor 00380 * 00381 * There is no normalization option as with other derivative kernels 00382 * since the harris kernel does not have a low-pass component. 00383 */ 00384 harrisKernelYY(); 00385 }; 00386 00387 /** 00388 * Robinson Kernel XX 00389 * 00390 * Define as a 5x5 2D (non-separable) kernel: 00391 * 00392 * \code 00393 * 1 2 -1 -2 1 00394 * 2 -2 -8 2 2 00395 * 3 0 0 0 3 00396 * 2 -2 -8 2 2 00397 * 1 2 -1 -2 1 00398 * \endcode 00399 */ 00400 template<class T> 00401 class robinsonKernelXX : public kernel2D<T> { 00402 public: 00403 /** 00404 * Constructor 00405 */ 00406 robinsonKernelXX(); 00407 }; 00408 00409 /** 00410 * Robinson Kernel XY 00411 * 00412 * Defined as a 5x5 2D (non separable) kernel: 00413 * 00414 * \code 00415 * 1 2 1 0 -1 00416 * 2 -2 -4 0 -2 00417 * 1 -4 4 0 -1 00418 * 0 0 0 6 0 00419 * -1 -2 -1 0 -1 00420 * \endcode 00421 */ 00422 template<class T> 00423 class robinsonKernelXY : public kernel2D<T> { 00424 public: 00425 /** 00426 * Constructor 00427 */ 00428 robinsonKernelXY(); 00429 }; 00430 00431 /** 00432 * Robinson Kernel YY 00433 * 00434 * Define as a 5x5 2D (non-separable) kernel: 00435 * 00436 * \code 00437 * 1 2 3 2 1 00438 * 2 -2 0 -2 2 00439 * -1 -8 0 -8 -1 00440 * -2 2 0 2 -2 00441 * 1 2 3 2 1 00442 * \endcode 00443 */ 00444 template<class T> 00445 class robinsonKernelYY : public kernel2D<T> { 00446 public: 00447 /** 00448 * Constructor 00449 */ 00450 robinsonKernelYY(); 00451 }; 00452 00453 /** 00454 * Kirsch Kernel XX 00455 * 00456 * Define as a 5x5 2D (non-separable) kernel: 00457 * 00458 * \code 00459 * 9 18 -21 -30 25 00460 * 18 18 -51 -30 50 00461 * 27 36 -72 -60 75 00462 * 18 18 -51 -30 50 00463 * 9 18 -21 -30 25 00464 * \endcode 00465 */ 00466 template<class T> 00467 class kirschKernelXX : public kernel2D<T> { 00468 public: 00469 /** 00470 * Constructor 00471 */ 00472 kirschKernelXX(); 00473 }; 00474 00475 /** 00476 * Kirsch Kernel XY 00477 * 00478 * Define as a 5x5 2D (non-separable) kernel: 00479 * 00480 * \code 00481 * 9 18 3 -6 -15 00482 * 18 18 -12 -6 -30 00483 * 3 -12 -8 4 -5 00484 * -6 -6 4 34 10 00485 * -15 -30 -5 10 25 00486 * \endcode 00487 */ 00488 template<class T> 00489 class kirschKernelXY : public kernel2D<T> { 00490 public: 00491 /** 00492 * Constructor 00493 */ 00494 kirschKernelXY(); 00495 }; 00496 00497 /** 00498 * Kirsch Kernel YY 00499 * 00500 * Define as a 5x5 2D (non-separable) kernel: 00501 * 00502 * \code 00503 * 9 18 27 18 9 00504 * 18 18 36 18 18 00505 * -21 -51 -72 -51 -21 00506 * 18 18 36 18 18 00507 * 9 18 27 18 9 00508 * \endcode 00509 */ 00510 template<class T> 00511 class kirschKernelYY : public kernel2D<T> { 00512 public: 00513 /** 00514 * Constructor 00515 */ 00516 kirschKernelYY(); 00517 }; 00518 } 00519 00520 #include "ltiSecondDerivativeKernels_template.h" 00521 00522 #endif