This file is indexed.

/usr/include/vigra/affinegeometry.hxx is in libvigraimpex-dev 1.10.0+dfsg-11ubuntu2.

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
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
/************************************************************************/
/*                                                                      */
/*               Copyright 2005-2006 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_AFFINEGEOMETRY_HXX
#define VIGRA_AFFINEGEOMETRY_HXX

#include "mathutil.hxx"
#include "matrix.hxx"
#include "tinyvector.hxx"
#include "splineimageview.hxx"
#include "multi_shape.hxx"

#include <cmath>

namespace vigra {

/** \addtogroup GeometricTransformations Geometric Transformations
*/
//@{

/********************************************************/
/*                                                      */
/*                create affine matrices                */
/*                                                      */
/********************************************************/

/** \brief Create homogeneous matrix representing a 2D translation.
 
    For use with \ref affineWarpImage().
*/
inline
linalg::TemporaryMatrix<double> translationMatrix2D(TinyVector<double, 2> const & shift)
{
    linalg::TemporaryMatrix<double> ret(identityMatrix<double>(3));
    ret(0,2) = shift[0];
    ret(1,2) = shift[1];
    return ret;
}

/** \brief Create homogeneous matrix representing a 2D uniform scaling about the coordinate origin.
 
    For use with \ref affineWarpImage().
*/
inline
linalg::TemporaryMatrix<double> scalingMatrix2D(double scalingFactor)
{
    linalg::TemporaryMatrix<double> ret(identityMatrix<double>(3));
    ret(0,0) = scalingFactor;
    ret(1,1) = scalingFactor;
    return ret;
}

/** \brief Create homogeneous matrix representing a 2D non-uniform scaling about the coordinate origin.
 
    For use with \ref affineWarpImage().
*/
inline
linalg::TemporaryMatrix<double> scalingMatrix2D(double sx, double sy)
{
    linalg::TemporaryMatrix<double> ret(identityMatrix<double>(3));
    ret(0,0) = sx;
    ret(1,1) = sy;
    return ret;
}

/** \brief Create homogeneous matrix representing a 2D shearing.
 
    For use with \ref affineWarpImage().
*/
inline
linalg::TemporaryMatrix<double> shearMatrix2D(double s01, double s10)
{
    linalg::TemporaryMatrix<double> ret(identityMatrix<double>(3));
    ret(0,1) = s01;
    ret(1,0) = s10;
    return ret;
}

/** \brief Create homogeneous matrix representing a 2D rotation about the coordinate origin.
 
    For use with \ref affineWarpImage(). Angle must be in radians.
*/
inline
linalg::TemporaryMatrix<double> rotationMatrix2DRadians(double angle)
{
    linalg::TemporaryMatrix<double> ret(identityMatrix<double>(3));
    double s = std::sin(angle);
    double c = std::cos(angle);
    ret(0,0) = c;
    ret(1,1) = c;
    ret(0,1) = -s;
    ret(1,0) = s;
    return ret;
}

/** \brief Create homogeneous matrix representing a 2D rotation about the coordinate origin.
 
    For use with \ref affineWarpImage(). Angle must be in degrees.
*/
inline
linalg::TemporaryMatrix<double> rotationMatrix2DDegrees(double angle)
{
    return rotationMatrix2DRadians(angle*M_PI/180.0);
}

/** \brief Create homogeneous matrix representing a 2D rotation about the given point.
 
    For use with \ref affineWarpImage(). Angle must be in radians.
*/
inline
linalg::TemporaryMatrix<double> rotationMatrix2DRadians(double angle, TinyVector<double, 2> const & center)
{
    return translationMatrix2D(center) * rotationMatrix2DRadians(angle) * translationMatrix2D(-center);
}

/** \brief Create homogeneous matrix representing a 2D rotation about the given point.
 
    For use with \ref affineWarpImage(). Angle must be in degrees.
*/
inline
linalg::TemporaryMatrix<double> rotationMatrix2DDegrees(double angle, TinyVector<double, 2> const & center)
{
    return rotationMatrix2DRadians(angle*M_PI/180.0, center);
}

/********************************************************/
/*                                                      */
/*                      rotateImage                     */
/*                                                      */
/********************************************************/

// documentation is in basicgeometry.hxx
template <int ORDER, class T, 
          class DestIterator, class DestAccessor>
void rotateImage(SplineImageView<ORDER, T> const & src,
                 DestIterator id, DestAccessor dest, 
                 double angleInDegree, TinyVector<double, 2> const & center)
{
    int w = src.width();
    int h = src.height();
    
    double angle = angleInDegree/180.0;
    double c = cos_pi(angle); // avoid round-off errors for simple rotations
    double s = sin_pi(angle);
    
    for(int y = 0; y < h; ++y, ++id.y)
    {
        typename DestIterator::row_iterator rd = id.rowIterator();
        double sy =  (y - center[1])*c - center[0]*s + center[1];
        double sx = -(y - center[1])*s - center[0]*c + center[0];
        for(int x=0; x < w; ++x, ++rd, sx += c, sy += s)
        {
            if(src.isInside(sx, sy))
                dest.set(src(sx, sy), rd);
        }
    }
}

template <int ORDER, class T, 
          class DestIterator, class DestAccessor>
inline void 
rotateImage(SplineImageView<ORDER, T> const & src,
            pair<DestIterator, DestAccessor> dest, 
            double angleInDegree, TinyVector<double, 2> const & center)
{
    rotateImage(src, dest.first, dest.second, angleInDegree, center);
}

template <int ORDER, class T, 
          class DestIterator, class DestAccessor>
inline void 
rotateImage(SplineImageView<ORDER, T> const & src,
            DestIterator id, DestAccessor dest, 
            double angleInDegree)
{
    TinyVector<double, 2> center((src.width()-1.0) / 2.0, (src.height()-1.0) / 2.0);
    rotateImage(src, id, dest, angleInDegree, center);
}

template <int ORDER, class T, 
          class DestIterator, class DestAccessor>
inline void 
rotateImage(SplineImageView<ORDER, T> const & src,
            pair<DestIterator, DestAccessor> dest, 
            double angleInDegree)
{
    TinyVector<double, 2> center((src.width()-1.0) / 2.0, (src.height()-1.0) / 2.0);
    rotateImage(src, dest.first, dest.second, angleInDegree, center);
}

template <int ORDER, class T, 
          class T2, class S2>
inline void 
rotateImage(SplineImageView<ORDER, T> const & src,
            MultiArrayView<2, T2, S2> dest, 
            double angleInDegree, TinyVector<double, 2> const & center)
{
    rotateImage(src, destImage(dest), angleInDegree, center);
}

template <int ORDER, class T, 
          class T2, class S2>
inline void 
rotateImage(SplineImageView<ORDER, T> const & src,
            MultiArrayView<2, T2, S2> dest, 
            double angleInDegree)
{
    TinyVector<double, 2> center((src.width()-1.0) / 2.0, (src.height()-1.0) / 2.0);
    rotateImage(src, destImage(dest), angleInDegree, center);
}

/********************************************************/
/*                                                      */
/*                  affineWarpImage                     */
/*                                                      */
/********************************************************/

/** \brief Warp an image according to an affine transformation.

    <b> Declarations:</b>
    
    pass 2D array views:
    \code
    namespace vigra {
        template <int ORDER, class T, 
                  class T2, class S2,
                  class C>
        void
        affineWarpImage(SplineImageView<ORDER, T> const & src,
                        MultiArrayView<2, T2, S2> dest, 
                        MultiArrayView<2, double, C> const & affineMatrix);
    }
    \endcode
    
    \deprecatedAPI{affineWarpImage}
    pass \ref ImageIterators and \ref DataAccessors :
    \code
    namespace vigra {
        template <int ORDER, class T, 
                class DestIterator, class DestAccessor,
                class C>
        void affineWarpImage(SplineImageView<ORDER, T> const & src,
                            DestIterator dul, DestIterator dlr, DestAccessor dest, 
                            MultiArrayView<2, double, C> const & affineMatrix);
    }
    \endcode
    use argument objects in conjunction with \ref ArgumentObjectFactories :
    \code
    namespace vigra {
        template <int ORDER, class T, 
                class DestIterator, class DestAccessor,
                class C>
        void affineWarpImage(SplineImageView<ORDER, T> const & src,
                            triple<DestIterator, DestIterator, DestAccessor> dest, 
                            MultiArrayView<2, double, C> const & affineMatrix);
    }
    \endcode
    \deprecatedEnd
    
    The algorithm applies the given \a affineMatrix to the <i>destination coordinates</i> and copies
    the image value from the resulting source coordinates, using the given SplineImageView \a src for interpolation. 
    If the resulting coordinate is outside the source image, nothing will be written at that destination point.
    
    \code
        for all dest pixels:
            currentSrcCoordinate = affineMatrix * currentDestCoordinate;
            if src.isInside(currentSrcCoordinate):
                dest[currentDestCoordinate] = src[currentSrcCoordinate]; // copy an interpolated value
    \endcode
    
    The matrix represents a 2-dimensional affine transform by means of homogeneous coordinates,
    i.e. it must be a 3x3 matrix whose last row is (0,0,1).
    
    <b> Usage:</b>
    
    <b>\#include</b> \<vigra/affinegeometry.hxx\><br>
    Namespace: vigra

    \code
    MultiArray<2, float> src(width, height);
    SplineImageView<3, float> spline(src);
    
    MultiArray<2, float> dest1(src.shape());
    
    // equivalent (up to round-off errors) to 
    //     rotateImage(spline, dest1, 45.0);
    TinyVector<double, 2> center((width-1.0)/2.0, (height-1.0)/2.0);
    affineWarpImage(spline, dest1, rotationMatrix2DDegrees(45.0, center));
    
    MultiArray<2, float> dest2(2*width-1, 2*height-1);
    
    // equivalent (up to round-off errors) to 
    //     resizeImageSplineInterpolation(img, dest2);
    // note that scaleFactor = 0.5, because we must pass the transformation from destination to source
    affineWarpImage(spline, dest2, scalingMatrix2D(0.5));
    \endcode

    \deprecatedUsage{affineWarpImage}
    \code
    FImage src(width, height);
    SplineImageView<3, Image::value_type> spline(srcImageRange(src));
    
    FImage dest1(width, height);
    
    // equivalent (up to round-off errors) with 
    //     rotateImage(spline, destImage(dest1), 45.0);
    TinyVector<double, 2> center((width-1.0)/2.0, (height-1.0)/2.0);
    affineWarpImage(spline, destImageRange(dest1), rotationMatrix2DDegrees(45.0, center));
    
    FImage dest2(2*width-1, 2*height-1);
    
    // equivalent (up to round-off errors) with 
    //     resizeImageSplineInterpolation(srcImageRange(img), destImageRange(dest2));
    // note that scaleFactor = 0.5, because we must pass the transformation from destination to source
    affineWarpImage(spline, destImageRange(dest2), scalingMatrix2D(0.5));
    \endcode
    <b> Required Interface:</b>
    \code
    DestImageIterator dest_upperleft;
    
    double x = ..., y = ...;
    
    if (spline.isInside(x,y))
        dest_accessor.set(spline(x, y), dest_upperleft);
    \endcode
    \deprecatedEnd
    
    <b>See also:</b> Functions to specify affine transformation: \ref translationMatrix2D(), \ref scalingMatrix2D(), 
                    \ref shearMatrix2D(), \ref rotationMatrix2DRadians(), \ref rotationMatrix2DDegrees()
*/
doxygen_overloaded_function(template <...> void affineWarpImage)

template <int ORDER, class T, 
          class DestIterator, class DestAccessor,
          class C>
void affineWarpImage(SplineImageView<ORDER, T> const & src,
                     DestIterator dul, DestIterator dlr, DestAccessor dest, 
                     MultiArrayView<2, double, C> const & affineMatrix)
{
    vigra_precondition(rowCount(affineMatrix) == 3 && columnCount(affineMatrix) == 3 && 
                       affineMatrix(2,0) == 0.0 && affineMatrix(2,1) == 0.0 && affineMatrix(2,2) == 1.0,
        "affineWarpImage(): matrix doesn't represent an affine transformation with homogeneous 2D coordinates.");
         
    
    double w = dlr.x - dul.x;
    double h = dlr.y - dul.y;
    
    for(double y = 0.0; y < h; ++y, ++dul.y)
    {
        typename DestIterator::row_iterator rd = dul.rowIterator();
        for(double x=0.0; x < w; ++x, ++rd)
        {
            double sx = x*affineMatrix(0,0) + y*affineMatrix(0,1) + affineMatrix(0,2);
            double sy = x*affineMatrix(1,0) + y*affineMatrix(1,1) + affineMatrix(1,2);
            if(src.isInside(sx, sy))
                dest.set(src(sx, sy), rd);
        }
    }
}

template <int ORDER, class T, 
          class DestIterator, class DestAccessor,
          class C>
inline void
affineWarpImage(SplineImageView<ORDER, T> const & src,
                triple<DestIterator, DestIterator, DestAccessor> dest, 
                MultiArrayView<2, double, C> const & affineMatrix)
{
    affineWarpImage(src, dest.first, dest.second, dest.third, affineMatrix);
}

template <int ORDER, class T, 
          class T2, class S2,
          class C>
inline void
affineWarpImage(SplineImageView<ORDER, T> const & src,
                MultiArrayView<2, T2, S2> dest, 
                MultiArrayView<2, double, C> const & affineMatrix)
{
    affineWarpImage(src, destImageRange(dest), affineMatrix);
}


//@}

} // namespace vigra


#endif /* VIGRA_AFFINEGEOMETRY_HXX */