[ VIGRA Homepage | Function Index | Class Index | Namespaces | File List | Main Page ]
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.6.0, Aug 13 2008 ) */ 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 /* ullrich.koethe@iwr.uni-heidelberg.de or */ 00012 /* vigra@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 doxygen_overloaded_function(template <...> void gradientEnergyTensor) 00124 00125 template <class SrcIterator, class SrcAccessor, 00126 class DestIterator, class DestAccessor> 00127 void gradientEnergyTensor(SrcIterator supperleft, SrcIterator slowerright, SrcAccessor src, 00128 DestIterator dupperleft, DestAccessor dest, 00129 Kernel1D<double> const & derivKernel, Kernel1D<double> const & smoothKernel) 00130 { 00131 vigra_precondition(dest.size(dupperleft) == 3, 00132 "gradientEnergyTensor(): output image must have 3 bands."); 00133 00134 int w = slowerright.x - supperleft.x; 00135 int h = slowerright.y - supperleft.y; 00136 00137 typedef typename 00138 NumericTraits<typename SrcAccessor::value_type>::RealPromote TmpType; 00139 typedef BasicImage<TmpType> TmpImage; 00140 TmpImage gx(w, h), gy(w, h), 00141 gxx(w, h), gxy(w, h), gyy(w, h), 00142 laplace(w, h), gx3(w, h), gy3(w, h); 00143 00144 convolveImage(srcIterRange(supperleft, slowerright, src), destImage(gx), 00145 derivKernel, smoothKernel); 00146 convolveImage(srcIterRange(supperleft, slowerright, src), destImage(gy), 00147 smoothKernel, derivKernel); 00148 convolveImage(srcImageRange(gx), destImage(gxx), 00149 derivKernel, smoothKernel); 00150 convolveImage(srcImageRange(gx), destImage(gxy), 00151 smoothKernel, derivKernel); 00152 convolveImage(srcImageRange(gy), destImage(gyy), 00153 smoothKernel, derivKernel); 00154 combineTwoImages(srcImageRange(gxx), srcImage(gyy), destImage(laplace), 00155 std::plus<TmpType>()); 00156 convolveImage(srcImageRange(laplace), destImage(gx3), 00157 derivKernel, smoothKernel); 00158 convolveImage(srcImageRange(laplace), destImage(gy3), 00159 smoothKernel, derivKernel); 00160 typename TmpImage::iterator gxi = gx.begin(), 00161 gyi = gy.begin(), 00162 gxxi = gxx.begin(), 00163 gxyi = gxy.begin(), 00164 gyyi = gyy.begin(), 00165 gx3i = gx3.begin(), 00166 gy3i = gy3.begin(); 00167 for(int y = 0; y < h; ++y, ++dupperleft.y) 00168 { 00169 typename DestIterator::row_iterator d = dupperleft.rowIterator(); 00170 for(int x = 0; x < w; ++x, ++d, ++gxi, ++gyi, ++gxxi, ++gxyi, ++gyyi, ++gx3i, ++gy3i) 00171 { 00172 dest.setComponent(sq(*gxxi) + sq(*gxyi) - *gxi * *gx3i, d, 0); 00173 dest.setComponent(- *gxyi * (*gxxi + *gyyi) + 0.5 * (*gxi * *gy3i + *gyi * *gx3i), d, 1); 00174 dest.setComponent(sq(*gxyi) + sq(*gyyi) - *gyi * *gy3i, d, 2); 00175 } 00176 } 00177 } 00178 00179 template <class SrcIterator, class SrcAccessor, 00180 class DestIterator, class DestAccessor> 00181 inline 00182 void gradientEnergyTensor(triple<SrcIterator, SrcIterator, SrcAccessor> src, 00183 pair<DestIterator, DestAccessor> dest, 00184 Kernel1D<double> const & derivKernel, Kernel1D<double> const & smoothKernel) 00185 { 00186 gradientEnergyTensor(src.first, src.second, src.third, 00187 dest.first, dest.second, derivKernel, smoothKernel); 00188 } 00189 00190 //@} 00191 00192 } // namespace vigra 00193 00194 #endif // VIGRA_GRADIENT_ENERGY_TENSOR_HXX
© Ullrich Köthe (ullrich.koethe@iwr.uni-heidelberg.de) |
html generated using doxygen and Python
|