[ VIGRA Homepage | Class Index | Function Index | File Index | Main Page ]
![]() |
vigra/gradient_energy_tensor.hxx | ![]() |
---|
00001 /************************************************************************/ 00002 /* */ 00003 /* Copyright 2004-2005 by Ullrich Koethe */ 00004 /* Cognitive Systems Group, University of Hamburg, Germany */ 00005 /* */ 00006 /* This file is part of the VIGRA computer vision library. */ 00007 /* ( Version 1.5.0, Dec 07 2006 ) */ 00008 /* The VIGRA Website is */ 00009 /* http://kogs-www.informatik.uni-hamburg.de/~koethe/vigra/ */ 00010 /* Please direct questions, bug reports, and contributions to */ 00011 /* koethe@informatik.uni-hamburg.de or */ 00012 /* vigra@kogs1.informatik.uni-hamburg.de */ 00013 /* */ 00014 /* Permission is hereby granted, free of charge, to any person */ 00015 /* obtaining a copy of this software and associated documentation */ 00016 /* files (the "Software"), to deal in the Software without */ 00017 /* restriction, including without limitation the rights to use, */ 00018 /* copy, modify, merge, publish, distribute, sublicense, and/or */ 00019 /* sell copies of the Software, and to permit persons to whom the */ 00020 /* Software is furnished to do so, subject to the following */ 00021 /* conditions: */ 00022 /* */ 00023 /* The above copyright notice and this permission notice shall be */ 00024 /* included in all copies or substantial portions of the */ 00025 /* Software. */ 00026 /* */ 00027 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND */ 00028 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES */ 00029 /* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND */ 00030 /* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT */ 00031 /* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, */ 00032 /* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING */ 00033 /* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR */ 00034 /* OTHER DEALINGS IN THE SOFTWARE. */ 00035 /* */ 00036 /************************************************************************/ 00037 00038 00039 #ifndef VIGRA_GRADIENT_ENERGY_TENSOR_HXX 00040 #define VIGRA_GRADIENT_ENERGY_TENSOR_HXX 00041 00042 #include <cmath> 00043 #include <functional> 00044 #include "utilities.hxx" 00045 #include "array_vector.hxx" 00046 #include "basicimage.hxx" 00047 #include "combineimages.hxx" 00048 #include "numerictraits.hxx" 00049 #include "convolution.hxx" 00050 00051 namespace vigra { 00052 00053 /** \addtogroup TensorImaging Tensor Image Processing 00054 */ 00055 //@{ 00056 00057 /********************************************************/ 00058 /* */ 00059 /* gradientEnergyTensor */ 00060 /* */ 00061 /********************************************************/ 00062 00063 /** \brief Calculate the gradient energy tensor for a scalar valued image. 00064 00065 These function calculates the gradient energy tensor (GET operator) as described in 00066 00067 M. Felsberg, U. Köthe: 00068 <i>"GET: The Connection Between Monogenic Scale-Space and Gaussian Derivatives"</i>, 00069 in: R. Kimmel, N. Sochen, J. Weickert (Eds.): Scale Space and PDE Methods in Computer Vision, 00070 Proc. of Scale-Space 2005, Lecture Notes in Computer Science 3459, pp. 192-203, Heidelberg: Springer, 2005. 00071 00072 U. Köthe, M. Felsberg: 00073 <i>"Riesz-Transforms Versus Derivatives: On the Relationship Between the Boundary Tensor and the Energy Tensor"</i>, 00074 in: ditto, pp. 179-191. 00075 00076 with the given filters: The derivative filter \a derivKernel is applied to the appropriate image dimensions 00077 in turn (see the papers above for details), and the other dimension is smoothed with \a smoothKernel. 00078 The kernels can be as small as 3x1, e.g. [0.5, 0, -0.5] and [3.0/16.0, 10.0/16.0, 3.0/16.0] respectively. 00079 The output image must have 3 bands which will hold the 00080 tensor components in the order t11, t12 (== t21), t22. The signs of the output are adjusted for a right-handed 00081 coordinate system. Thus, orientations derived from the tensor will be in counter-clockwise (mathematically positive) 00082 order, with the x-axis at zero degrees (this is the standard in all VIGRA functions that deal with orientation). 00083 00084 <b> Declarations:</b> 00085 00086 pass arguments explicitly: 00087 \code 00088 namespace vigra { 00089 template <class SrcIterator, class SrcAccessor, 00090 class DestIterator, class DestAccessor> 00091 void gradientEnergyTensor(SrcIterator supperleft, SrcIterator slowerright, SrcAccessor src, 00092 DestIterator dupperleft, DestAccessor dest, 00093 Kernel1D<double> const & derivKernel, Kernel1D<double> const & smoothKernel); 00094 } 00095 \endcode 00096 00097 use argument objects in conjunction with \ref ArgumentObjectFactories: 00098 \code 00099 namespace vigra { 00100 template <class SrcIterator, class SrcAccessor, 00101 class DestIterator, class DestAccessor> 00102 void gradientEnergyTensor(triple<SrcIterator, SrcIterator, SrcAccessor> src, 00103 pair<DestIterator, DestAccessor> dest, 00104 Kernel1D<double> const & derivKernel, Kernel1D<double> const & smoothKernel); 00105 } 00106 \endcode 00107 00108 <b> Usage:</b> 00109 00110 <b>\#include</b> "<a href="gradient__energy__tensor_8hxx-source.html">vigra/gradient_energy_tensor.hxx</a>" 00111 00112 \code 00113 FImage img(w,h); 00114 FVector3Image get(w,h); 00115 Kernel1D<double> grad, smooth; 00116 grad.initGaussianDerivative(0.7, 1); 00117 smooth.initGaussian(0.7); 00118 ... 00119 gradientEnergyTensor(srcImageRange(img), destImage(get), grad, smooth); 00120 \endcode 00121 00122 */ 00123 template <class SrcIterator, class SrcAccessor, 00124 class DestIterator, class DestAccessor> 00125 void gradientEnergyTensor(SrcIterator supperleft, SrcIterator slowerright, SrcAccessor src, 00126 DestIterator dupperleft, DestAccessor dest, 00127 Kernel1D<double> const & derivKernel, Kernel1D<double> const & smoothKernel) 00128 { 00129 vigra_precondition(dest.size(dupperleft) == 3, 00130 "gradientEnergyTensor(): output image must have 3 bands."); 00131 00132 int w = slowerright.x - supperleft.x; 00133 int h = slowerright.y - supperleft.y; 00134 00135 typedef typename 00136 NumericTraits<typename SrcAccessor::value_type>::RealPromote TmpType; 00137 typedef BasicImage<TmpType> TmpImage; 00138 TmpImage gx(w, h), gy(w, h), 00139 gxx(w, h), gxy(w, h), gyy(w, h), 00140 laplace(w, h), gx3(w, h), gy3(w, h); 00141 00142 convolveImage(srcIterRange(supperleft, slowerright, src), destImage(gx), 00143 derivKernel, smoothKernel); 00144 convolveImage(srcIterRange(supperleft, slowerright, src), destImage(gy), 00145 smoothKernel, derivKernel); 00146 convolveImage(srcImageRange(gx), destImage(gxx), 00147 derivKernel, smoothKernel); 00148 convolveImage(srcImageRange(gx), destImage(gxy), 00149 smoothKernel, derivKernel); 00150 convolveImage(srcImageRange(gy), destImage(gyy), 00151 smoothKernel, derivKernel); 00152 combineTwoImages(srcImageRange(gxx), srcImage(gyy), destImage(laplace), 00153 std::plus<TmpType>()); 00154 convolveImage(srcImageRange(laplace), destImage(gx3), 00155 derivKernel, smoothKernel); 00156 convolveImage(srcImageRange(laplace), destImage(gy3), 00157 smoothKernel, derivKernel); 00158 typename TmpImage::iterator gxi = gx.begin(), 00159 gyi = gy.begin(), 00160 gxxi = gxx.begin(), 00161 gxyi = gxy.begin(), 00162 gyyi = gyy.begin(), 00163 gx3i = gx3.begin(), 00164 gy3i = gy3.begin(); 00165 for(int y = 0; y < h; ++y, ++dupperleft.y) 00166 { 00167 typename DestIterator::row_iterator d = dupperleft.rowIterator(); 00168 for(int x = 0; x < w; ++x, ++d, ++gxi, ++gyi, ++gxxi, ++gxyi, ++gyyi, ++gx3i, ++gy3i) 00169 { 00170 dest.setComponent(sq(*gxxi) + sq(*gxyi) - *gxi * *gx3i, d, 0); 00171 dest.setComponent(- *gxyi * (*gxxi + *gyyi) + 0.5 * (*gxi * *gy3i + *gyi * *gx3i), d, 1); 00172 dest.setComponent(sq(*gxyi) + sq(*gyyi) - *gyi * *gy3i, d, 2); 00173 } 00174 } 00175 } 00176 00177 template <class SrcIterator, class SrcAccessor, 00178 class DestIterator, class DestAccessor> 00179 inline 00180 void gradientEnergyTensor(triple<SrcIterator, SrcIterator, SrcAccessor> src, 00181 pair<DestIterator, DestAccessor> dest, 00182 Kernel1D<double> const & derivKernel, Kernel1D<double> const & smoothKernel) 00183 { 00184 gradientEnergyTensor(src.first, src.second, src.third, 00185 dest.first, dest.second, derivKernel, smoothKernel); 00186 } 00187 00188 //@} 00189 00190 } // namespace vigra 00191 00192 #endif // VIGRA_GRADIENT_ENERGY_TENSOR_HXX
© Ullrich Köthe (koethe@informatik.uni-hamburg.de) |
html generated using doxygen and Python
|