/usr/include/vigra/gradient_energy_tensor.hxx is in libvigraimpex-dev 1.10.0+dfsg-3ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | /************************************************************************/
/* */
/* Copyright 2004-2005 by Ullrich Koethe */
/* */
/* This file is part of the VIGRA computer vision library. */
/* The VIGRA Website is */
/* http://hci.iwr.uni-heidelberg.de/vigra/ */
/* Please direct questions, bug reports, and contributions to */
/* ullrich.koethe@iwr.uni-heidelberg.de or */
/* vigra@informatik.uni-hamburg.de */
/* */
/* Permission is hereby granted, free of charge, to any person */
/* obtaining a copy of this software and associated documentation */
/* files (the "Software"), to deal in the Software without */
/* restriction, including without limitation the rights to use, */
/* copy, modify, merge, publish, distribute, sublicense, and/or */
/* sell copies of the Software, and to permit persons to whom the */
/* Software is furnished to do so, subject to the following */
/* conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the */
/* Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES */
/* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND */
/* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT */
/* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, */
/* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING */
/* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR */
/* OTHER DEALINGS IN THE SOFTWARE. */
/* */
/************************************************************************/
#ifndef VIGRA_GRADIENT_ENERGY_TENSOR_HXX
#define VIGRA_GRADIENT_ENERGY_TENSOR_HXX
#include <cmath>
#include <functional>
#include "utilities.hxx"
#include "array_vector.hxx"
#include "basicimage.hxx"
#include "combineimages.hxx"
#include "numerictraits.hxx"
#include "convolution.hxx"
#include "multi_shape.hxx"
namespace vigra {
/** \addtogroup TensorImaging Tensor Image Processing
*/
//@{
/********************************************************/
/* */
/* gradientEnergyTensor */
/* */
/********************************************************/
/** \brief Calculate the gradient energy tensor for a scalar valued image.
These function calculates the gradient energy tensor (GET operator) as described in
M. Felsberg, U. Köthe:
<i>"GET: The Connection Between Monogenic Scale-Space and Gaussian Derivatives"</i>,
in: R. Kimmel, N. Sochen, J. Weickert (Eds.): Scale Space and PDE Methods in Computer Vision,
Proc. of Scale-Space 2005, Lecture Notes in Computer Science 3459, pp. 192-203, Heidelberg: Springer, 2005.
U. Köthe, M. Felsberg:
<i>"Riesz-Transforms Versus Derivatives: On the Relationship Between the Boundary Tensor and the Energy Tensor"</i>,
in: ditto, pp. 179-191.
with the given filters: The derivative filter \a derivKernel is applied to the appropriate image dimensions
in turn (see the papers above for details), and the other dimension is smoothed with \a smoothKernel.
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.
The output image must have 3 bands which will hold the
tensor components in the order t11, t12 (== t21), t22. The signs of the output are adjusted for a right-handed
coordinate system. Thus, orientations derived from the tensor will be in counter-clockwise (mathematically positive)
order, with the x-axis at zero degrees (this is the standard in all VIGRA functions that deal with orientation).
<b> Declarations:</b>
pass 2D array views:
\code
namespace vigra {
template <class T1, class S1,
class T2, class S2>
void
gradientEnergyTensor(MultiArrayView<2, T1, S1> const & src,
MultiArrayView<2, T2, S2> dest,
Kernel1D<double> const & derivKernel, Kernel1D<double> const & smoothKernel);
}
\endcode
\deprecatedAPI{gradientEnergyTensor}
pass \ref ImageIterators and \ref DataAccessors :
\code
namespace vigra {
template <class SrcIterator, class SrcAccessor,
class DestIterator, class DestAccessor>
void gradientEnergyTensor(SrcIterator supperleft, SrcIterator slowerright, SrcAccessor src,
DestIterator dupperleft, DestAccessor dest,
Kernel1D<double> const & derivKernel, Kernel1D<double> const & smoothKernel);
}
\endcode
use argument objects in conjunction with \ref ArgumentObjectFactories :
\code
namespace vigra {
template <class SrcIterator, class SrcAccessor,
class DestIterator, class DestAccessor>
void gradientEnergyTensor(triple<SrcIterator, SrcIterator, SrcAccessor> src,
pair<DestIterator, DestAccessor> dest,
Kernel1D<double> const & derivKernel, Kernel1D<double> const & smoothKernel);
}
\endcode
\deprecatedEnd
<b> Usage:</b>
<b>\#include</b> \<vigra/gradient_energy_tensor.hxx\><br/>
Namespace: vigra
\code
MultiArray<2, float> img(w,h);
MultiArray<2, TinyVector<float, 3> > get(w,h);
Kernel1D<double> grad, smooth;
grad.initGaussianDerivative(0.7, 1);
smooth.initGaussian(0.7);
...
gradientEnergyTensor(img, get, grad, smooth);
\endcode
\deprecatedUsage{gradientEnergyTensor}
\code
FImage img(w,h);
FVector3Image get(w,h);
Kernel1D<double> grad, smooth;
grad.initGaussianDerivative(0.7, 1);
smooth.initGaussian(0.7);
...
gradientEnergyTensor(srcImageRange(img), destImage(get), grad, smooth);
\endcode
\deprecatedEnd
*/
doxygen_overloaded_function(template <...> void gradientEnergyTensor)
template <class SrcIterator, class SrcAccessor,
class DestIterator, class DestAccessor>
void gradientEnergyTensor(SrcIterator supperleft, SrcIterator slowerright, SrcAccessor src,
DestIterator dupperleft, DestAccessor dest,
Kernel1D<double> const & derivKernel, Kernel1D<double> const & smoothKernel)
{
vigra_precondition(dest.size(dupperleft) == 3,
"gradientEnergyTensor(): output image must have 3 bands.");
int w = slowerright.x - supperleft.x;
int h = slowerright.y - supperleft.y;
typedef typename
NumericTraits<typename SrcAccessor::value_type>::RealPromote TmpType;
typedef BasicImage<TmpType> TmpImage;
TmpImage gx(w, h), gy(w, h),
gxx(w, h), gxy(w, h), gyy(w, h),
laplace(w, h), gx3(w, h), gy3(w, h);
convolveImage(srcIterRange(supperleft, slowerright, src), destImage(gx),
derivKernel, smoothKernel);
convolveImage(srcIterRange(supperleft, slowerright, src), destImage(gy),
smoothKernel, derivKernel);
convolveImage(srcImageRange(gx), destImage(gxx),
derivKernel, smoothKernel);
convolveImage(srcImageRange(gx), destImage(gxy),
smoothKernel, derivKernel);
convolveImage(srcImageRange(gy), destImage(gyy),
smoothKernel, derivKernel);
combineTwoImages(srcImageRange(gxx), srcImage(gyy), destImage(laplace),
std::plus<TmpType>());
convolveImage(srcImageRange(laplace), destImage(gx3),
derivKernel, smoothKernel);
convolveImage(srcImageRange(laplace), destImage(gy3),
smoothKernel, derivKernel);
typename TmpImage::iterator gxi = gx.begin(),
gyi = gy.begin(),
gxxi = gxx.begin(),
gxyi = gxy.begin(),
gyyi = gyy.begin(),
gx3i = gx3.begin(),
gy3i = gy3.begin();
for(int y = 0; y < h; ++y, ++dupperleft.y)
{
typename DestIterator::row_iterator d = dupperleft.rowIterator();
for(int x = 0; x < w; ++x, ++d, ++gxi, ++gyi, ++gxxi, ++gxyi, ++gyyi, ++gx3i, ++gy3i)
{
dest.setComponent(sq(*gxxi) + sq(*gxyi) - *gxi * *gx3i, d, 0);
dest.setComponent(- *gxyi * (*gxxi + *gyyi) + 0.5 * (*gxi * *gy3i + *gyi * *gx3i), d, 1);
dest.setComponent(sq(*gxyi) + sq(*gyyi) - *gyi * *gy3i, d, 2);
}
}
}
template <class SrcIterator, class SrcAccessor,
class DestIterator, class DestAccessor>
inline void
gradientEnergyTensor(triple<SrcIterator, SrcIterator, SrcAccessor> src,
pair<DestIterator, DestAccessor> dest,
Kernel1D<double> const & derivKernel, Kernel1D<double> const & smoothKernel)
{
gradientEnergyTensor(src.first, src.second, src.third,
dest.first, dest.second, derivKernel, smoothKernel);
}
template <class T1, class S1,
class T2, class S2>
inline void
gradientEnergyTensor(MultiArrayView<2, T1, S1> const & src,
MultiArrayView<2, T2, S2> dest,
Kernel1D<double> const & derivKernel, Kernel1D<double> const & smoothKernel)
{
vigra_precondition(src.shape() == dest.shape(),
"gradientEnergyTensor(): shape mismatch between input and output.");
gradientEnergyTensor(srcImageRange(src),
destImage(dest), derivKernel, smoothKernel);
}
//@}
} // namespace vigra
#endif // VIGRA_GRADIENT_ENERGY_TENSOR_HXX
|