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