This file is indexed.

/usr/include/vigra/rbf_registration.hxx is in libvigraimpex-dev 1.10.0+git20160211.167be93+dfsg-2+b5.

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 2007-2014 by Benjamin Seppke                 */
/*                                                                      */
/*    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_RBF_REGISTRATION_HXX
#define VIGRA_RBF_REGISTRATION_HXX

#include <vigra/mathutil.hxx>
#include <vigra/matrix.hxx>
#include <vigra/linear_solve.hxx>
#include <vigra/tinyvector.hxx>
#include <vigra/splineimageview.hxx>
#include <vigra/affine_registration.hxx>

namespace vigra {

/** \addtogroup Registration Image Registration
 */
//@{

namespace detail {

// Small and hopefully fast helper function to compute the squared-distance
// between two points (2d)
template <class SrcPoint, class DestPoint>
inline double distance2(SrcPoint const & p1, DestPoint const & p2)
{
    return (double)(p1[0]-p2[0])*(p1[0]-p2[0]) + (p1[1]-p2[1])*(p1[1]-p2[1]);
}

} //end of namespace vigra::detail


/**
 * The famous thin plate spline functor [weight(d) = d^2*log(d^2)]
 * only affects up to max distance...
 */
struct ThinPlateSplineFunctor
{
    template <class SrcPoint, class DestPoint>
    inline double operator()(SrcPoint const & p1, DestPoint const & p2) const
    {
        double dist2 = detail::distance2(p1, p2);

        if(dist2 == 0 )
        {
            return 0;
        }
        else
        {
            return dist2*log(dist2);
        }
    }
};

/**
 * A distance power based radial basis functor [weight = dist^N]
 */
template<int N>
struct DistancePowerFunctor
{
    template <class SrcPoint, class DestPoint>
    inline double operator()(SrcPoint const & p1, DestPoint const & p2) const
    {
        double dist2 = detail::distance2(p1, p2);

        if(dist2 == 0)
        {
            return 0;
        }
        else
        {
            return pow(dist2, N/2.0);
        }
    }
};

/********************************************************/
/*                                                      */
/*          rbfMatrix2DFromCorrespondingPoints          */
/*                                                      */
/********************************************************/

/** \brief Create a matrix that maps corresponding points onto each other using a given RBF.

 For use with \ref rbfWarpImage(). For n given (corresponding) points,
 the matrix will be of size (n+3,2). Note that the representation of this matrix is exactly
 the same as the "W" matrix of Bookstein. More information can be found in the following article:

 Fred L. Bookstein. Principal Warps: Thin-Plate Splines and the Decomposition of Deformations. IEEE PAMI, Vol 11, No 8. 1989
 */
template <class RadialBasisFunctor,
          class SrcPointIterator, class DestPointIterator>
linalg::TemporaryMatrix<double>
rbfMatrix2DFromCorrespondingPoints(SrcPointIterator s, SrcPointIterator s_end, DestPointIterator d, RadialBasisFunctor const & rbf)
{
    int point_count = s_end - s;

    Matrix<double> L(point_count+3, point_count+3, 0.0);
    Matrix<double> Y(point_count+3,               2, 0.0);
    Matrix<double> W(point_count+3,               2, 0.0);

    //fill P (directly into K) and V (directly into Y)
    for(int i=0; i<point_count; ++i)
    {
        L(i, point_count  ) = L(point_count,   i) = 1;
        L(i, point_count+1) = L(point_count+1, i) = (d[i])[0];
        L(i, point_count+2) = L(point_count+2, i) = (d[i])[1];

        Y(i,0)= (s[i])[0];
        Y(i,1)= (s[i])[1];
    }

    //fill K (directly into L)
    for(int j=0; j<point_count; j++)
    {
        for(int i=0; i<j; i++)
        {
            L(i,j) = L(j,i) = rbf(d[i], d[j]);
        }
    }

    linearSolve(L, Y, W);
    //Results are okay, even if vigra reports failure...
    //so I commented this out
    //    if(!linearSolve(L, Y, W))
    //        vigra_fail("radialBasisMatrix2DFromCorrespondingPoints(): singular solution matrix.");

    return W;
};


/********************************************************/
/*                                                      */
/*                     rbfWarpImage                     */
/*                                                      */
/********************************************************/

/** \brief Warp an image according to an radial basis function based transformation.

 To get more information about the structure of the matrix, see \ref rbfMatrix2DFromCorrespondingPoints()

 <b>\#include</b> \<vigra/rbf_registration.hxx\><br>
 Namespace: vigra

 pass 2D array views:
 \code
 namespace vigra {
     template <int ORDER, class T,
               class T2, class S2,
               class DestPointIterator,
               class C,
               class RadialBasisFunctor>
     void
     rbfWarpImage(SplineImageView<ORDER, T> const & src,
                  MultiArrayView<2, T2, S2> dest,
                  DestPointIterator d, DestPointIterator d_end,
                  MultiArrayView<2, double, C> const & W,
                  RadialBasisFunctor rbf);
 }
 \endcode

 \deprecatedAPI{rbfWarpImage}

 pass arguments explicitly:
 \code
 namespace vigra {
     template <int ORDER, class T,
               class DestIterator, class DestAccessor,
               class DestPointIterator,
               class C,
               class RadialBasisFunctor>
     void
     rbfWarpImage(SplineImageView<ORDER, T> const & src,
                  DestIterator dul, DestIterator dlr, DestAccessor dest,
                  DestPointIterator d, DestPointIterator d_end,
                  MultiArrayView<2, double, C> const & W,
                  RadialBasisFunctor rbf);
 }
 \endcode

 use argument objects in conjunction with \ref ArgumentObjectFactories :
 \code
 namespace vigra {
     template <int ORDER, class T,
               class DestIterator, class DestAccessor,
               class DestPointIterator,
               class C,
               class RadialBasisFunctor>
     void
     rbfWarpImage(SplineImageView<ORDER, T> const & src,
                  triple<DestIterator, DestIterator, DestAccessor> dest,
                  DestPointIterator d, DestPointIterator d_end,
                  MultiArrayView<2, double, C> const & W,
                  RadialBasisFunctor rbf);
 }
 }
 \endcode
 \deprecatedEnd
 */
template <int ORDER, class T,
          class DestIterator, class DestAccessor,
          class DestPointIterator,
          class C,
          class RadialBasisFunctor>
void
rbfWarpImage(SplineImageView<ORDER, T> const & src,
             DestIterator dul, DestIterator dlr, DestAccessor dest,
             DestPointIterator d, DestPointIterator d_end,
             MultiArrayView<2, double, C> const & W,
             RadialBasisFunctor rbf)
{
    int point_count = d_end - d;

    vigra_precondition(rowCount(W) == point_count+3 && columnCount(W) == 2,
                       "vigra::rbfWarpImage(): matrix doesn't represent a proper transformation of given point size in 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)
        {
            //Affine part
            double    sx = W(point_count,0)+W(point_count+1,0)*x+ W(point_count+2,0)*y,
                    sy = W(point_count,1)+W(point_count+1,1)*x+ W(point_count+2,1)*y;

            //RBS part
            for(int i=0; i<point_count; i++)
            {
                double weight = rbf(d[i], Diff2D(x,y));
                sx += W(i,0)*weight;
                sy += W(i,1)*weight;

            }

            if(src.isInside(sx, sy))
                dest.set(src(sx, sy), rd);
        }
    }
};

template <int ORDER, class T,
          class DestIterator, class DestAccessor,
          class DestPointIterator,
          class C,
          class RadialBasisFunctor>
inline
void rbfWarpImage(SplineImageView<ORDER, T> const & src,
                  triple<DestIterator, DestIterator, DestAccessor> dest,
                  DestPointIterator d, DestPointIterator d_end,
                  MultiArrayView<2, double, C> const & W,
                  RadialBasisFunctor rbf)
{
    rbfWarpImage(src, dest.first, dest.second, dest.third, d, d_end, W, rbf);
}

template <int ORDER, class T,
          class T2, class S2,
          class DestPointIterator,
          class C,
          class RadialBasisFunctor>
inline
void rbfWarpImage(SplineImageView<ORDER, T> const & src,
                  MultiArrayView<2, T2, S2> dest,
                  DestPointIterator d, DestPointIterator d_end,
                  MultiArrayView<2, double, C> const & W,
                  RadialBasisFunctor rbf)
{
    rbfWarpImage(src, destImageRange(dest), d, d_end, W, rbf);
}


//@}

} // namespace vigra


#endif /* VIGRA_RBF_REGISTRATION_HXX */