/usr/include/vigra/symmetry.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 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | /************************************************************************/
/* */
/* Copyright 1998-2002 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_SYMMETRY_HXX
#define VIGRA_SYMMETRY_HXX
#include "utilities.hxx"
#include "numerictraits.hxx"
#include "stdimage.hxx"
#include "convolution.hxx"
#include "multi_shape.hxx"
namespace vigra {
/** \addtogroup SymmetryDetection Symmetry Detection
Measure the local symmetry at each pixel.
*/
//@{
/********************************************************/
/* */
/* radialSymmetryTransform */
/* */
/********************************************************/
/** \brief Find centers of radial symmetry in an image.
This algorithm implements the Fast Radial Symmetry Transform according to
[G. Loy, A. Zelinsky: <em> "A Fast Radial Symmetry Transform for Detecting
Points of Interest"</em>, in: A. Heyden et al. (Eds.): Proc. of 7th European
Conf. on Computer Vision, Part 1, pp. 358-368, Springer LNCS 2350, 2002].
Minima of the algorithm response mark dark blobs, maxima correspond to light blobs.
The "radial strictness parameter" is fixed at <TT>alpha</tt> = 2.0, the
spatial spreading of the raw response is done by a Gaussian convolution
at <tt>0.25*scale</TT> (these values are recommendations from the paper).
Loy and Zelinsky additionally propose to add the operator response from several
scales (see usage example below).
<b> Declarations:</b>
pass 2D array views:
\code
namespace vigra {
template <class T1, class S1,
class T2, class S2>
void
radialSymmetryTransform(MultiArrayView<2, T1, S1> const & src,
MultiArrayView<2, T2, S2> dest,
double scale);
}
\endcode
\deprecatedAPI{radialSymmetryTransform}
pass \ref ImageIterators and \ref DataAccessors :
\code
namespace vigra {
template <class SrcIterator, class SrcAccessor,
class DestIterator, class DestAccessor>
void
radialSymmetryTransform(SrcIterator sul, SrcIterator slr, SrcAccessor as,
DestIterator dul, DestAccessor ad,
double scale)
}
\endcode
use argument objects in conjunction with \ref ArgumentObjectFactories :
\code
namespace vigra {
template <class SrcIterator, class SrcAccessor,
class DestIterator, class DestAccessor>
inline
void radialSymmetryTransform(
triple<SrcIterator, SrcIterator, SrcAccessor> src,
pair<DestIterator, DestAccessor> dest,
double scale)
}
\endcode
\deprecatedEnd
<b> Usage:</b>
<b>\#include</b> \<vigra/symmetry.hxx\><br>
Namespace: vigra
\code
MultiArray<2, unsigned char> src(w,h), centers(w,h);
MultiArray<2, float> symmetry(w,h);
// use edge detection filters at various scales
for(double scale = 2.0; scale <= 8.0; scale *= 2.0)
{
MultiArray<2, float> tmp(w,h);
// find centers of symmetry
radialSymmetryTransform(src, tmp, scale);
symmetry += tmp;
}
// mark centers of symmetry
centers.init(128);
localMinima(symmetry, centers, 0);
localMaxima(symmetry, centers, 255);
\endcode
\deprecatedUsage{radialSymmetryTransform}
\code
vigra::BImage src(w,h), centers(w,h);
vigra::FImage symmetry(w,h);
// empty result image
centers.init(128);
symmetry.init(0.0);
// input width of edge detection filter
for(double scale = 2.0; scale <= 8.0; scale *= 2.0)
{
vigra::FImage tmp(w,h);
// find centers of symmetry
radialSymmetryTransform(srcImageRange(src), destImage(tmp), scale);
combineTwoImages(srcImageRange(symmetry), srcImage(tmp), destImage(symmetry),
std::plus<float>());
}
localMinima(srcImageRange(symmetry), destImage(centers), 0);
localMaxima(srcImageRange(symmetry), destImage(centers), 255);
\endcode
<b> Required Interface:</b>
\code
SrcImageIterator src_upperleft, src_lowerright;
DestImageIterator dest_upperleft;
SrcAccessor src_accessor;
DestAccessor dest_accessor;
// SrcAccessor::value_type must be a built-in type
SrcAccessor::value_type u = src_accessor(src_upperleft);
dest_accessor.set(u, dest_upperleft);
\endcode
\deprecatedEnd
*/
doxygen_overloaded_function(template <...> void radialSymmetryTransform)
template <class SrcIterator, class SrcAccessor,
class DestIterator, class DestAccessor>
void
radialSymmetryTransform(SrcIterator sul, SrcIterator slr, SrcAccessor as,
DestIterator dul, DestAccessor ad,
double scale)
{
vigra_precondition(scale > 0.0,
"radialSymmetryTransform(): Scale must be > 0");
int w = slr.x - sul.x;
int h = slr.y - sul.y;
if(w <= 0 || h <= 0) return;
typedef typename
NumericTraits<typename SrcAccessor::value_type>::RealPromote TmpType;
typedef BasicImage<TmpType> TmpImage;
typedef typename TmpImage::Iterator TmpIterator;
TmpImage gx(w,h);
TmpImage gy(w,h);
IImage orientationCounter(w,h);
TmpImage magnitudeAccumulator(w,h);
gaussianGradient(srcIterRange(sul, slr, as),
destImage(gx), destImage(gy),
scale);
orientationCounter.init(0);
magnitudeAccumulator.init(NumericTraits<TmpType>::zero());
TmpIterator gxi = gx.upperLeft();
TmpIterator gyi = gy.upperLeft();
int y;
for(y=0; y<h; ++y, ++gxi.y, ++gyi.y)
{
typename TmpIterator::row_iterator gxr = gxi.rowIterator();
typename TmpIterator::row_iterator gyr = gyi.rowIterator();
for(int x = 0; x<w; ++x, ++gxr, ++gyr)
{
double angle = VIGRA_CSTD::atan2(-*gyr, *gxr);
double magnitude = VIGRA_CSTD::sqrt(*gxr * *gxr + *gyr * *gyr);
if(magnitude < NumericTraits<TmpType>::epsilon()*10.0)
continue;
int dx = NumericTraits<int>::fromRealPromote(scale * VIGRA_CSTD::cos(angle));
int dy = NumericTraits<int>::fromRealPromote(scale * VIGRA_CSTD::sin(angle));
int xx = x + dx;
int yy = y - dy;
if(xx >= 0 && xx < w && yy >= 0 && yy < h)
{
orientationCounter(xx, yy) += 1;
magnitudeAccumulator(xx, yy) += detail::RequiresExplicitCast<TmpType>::cast(magnitude);
}
xx = x - dx;
yy = y + dy;
if(xx >= 0 && xx < w && yy >= 0 && yy < h)
{
orientationCounter(xx, yy) -= 1;
magnitudeAccumulator(xx, yy) -= detail::RequiresExplicitCast<TmpType>::cast(magnitude);
}
}
}
int maxOrientation = 0;
TmpType maxMagnitude = NumericTraits<TmpType>::zero();
for(y=0; y<h; ++y)
{
for(int x = 0; x<w; ++x)
{
int o = VIGRA_CSTD::abs(orientationCounter(x,y));
if(o > maxOrientation)
maxOrientation = o;
TmpType m = VIGRA_CSTD::abs(magnitudeAccumulator(x,y));
if(m > maxMagnitude)
maxMagnitude = m;
}
}
for(y=0; y<h; ++y)
{
for(int x = 0; x<w; ++x)
{
double o = (double)orientationCounter(x, y) / maxOrientation;
magnitudeAccumulator(x, y) = detail::RequiresExplicitCast<TmpType>::cast(o * o * magnitudeAccumulator(x, y) / maxMagnitude);
}
}
gaussianSmoothing(srcImageRange(magnitudeAccumulator), destIter(dul, ad), 0.25*scale);
}
template <class SrcIterator, class SrcAccessor,
class DestIterator, class DestAccessor>
inline void
radialSymmetryTransform(triple<SrcIterator, SrcIterator, SrcAccessor> src,
pair<DestIterator, DestAccessor> dest,
double scale)
{
radialSymmetryTransform(src.first, src.second, src.third,
dest.first, dest.second,
scale);
}
template <class T1, class S1,
class T2, class S2>
inline void
radialSymmetryTransform(MultiArrayView<2, T1, S1> const & src,
MultiArrayView<2, T2, S2> dest,
double scale)
{
vigra_precondition(src.shape() == dest.shape(),
"radialSymmetryTransform(): shape mismatch between input and output.");
radialSymmetryTransform(srcImageRange(src),
destImage(dest),
scale);
}
//@}
} // namespace vigra
#endif /* VIGRA_SYMMETRY_HXX */
|