1 #ifndef _LSVM_DIST_TRANSFORM_H_
2 #define _LSVM_DIST_TRANSFORM_H_
4 #include "_lsvm_types.h"
5 #include "_lsvm_error.h"
8 // Computation the point of intersection functions
9 // (parabolas on the variable y)
10 // a(y - q1) + b(q1 - y)(q1 - y) + f[q1]
11 // a(y - q2) + b(q2 - y)(q2 - y) + f[q2]
14 // int GetPointOfIntersection(const F_type *f,
15 const F_type a, const F_type b,
16 int q1, int q2, F_type *point);
18 // f - function on the regular grid
19 // a - coefficient of the function
20 // b - coefficient of the function
21 // q1 - parameter of the function
22 // q2 - parameter of the function
24 // point - point of intersection
28 int GetPointOfIntersection(const float *f,
29 const float a, const float b,
30 int q1, int q2, float *point);
33 // Decision of one dimensional problem generalized distance transform
34 // on the regular grid at all points
35 // min (a(y' - y) + b(y' - y)(y' - y) + f(y')) (on y')
38 // int DistanceTransformOneDimensionalProblem(const F_type *f, const int n,
39 const F_type a, const F_type b,
40 F_type *distanceTransform,
43 // f - function on the regular grid
45 // a - coefficient of optimizable function
46 // b - coefficient of optimizable function
48 // distanceTransform - values of generalized distance transform
49 // points - arguments that corresponds to the optimal value of function
53 int DistanceTransformOneDimensionalProblem(const float *f, const int n,
54 const float a, const float b,
55 float *distanceTransform,
59 // Computation next cycle element
62 // int GetNextCycleElement(int k, int n, int q);
64 // k - index of the previous cycle element
65 // n - number of matrix rows
66 // q - parameter that equal (number_of_rows * number_of_columns - 1)
72 int GetNextCycleElement(int k, int n, int q);
75 // Transposition of cycle elements
78 // void TransposeCycleElements(F_type *a, int *cycle, int cycle_len);
82 // cycle_len - cycle length
84 // a - matrix with transposed elements
88 void TransposeCycleElements(float *a, int *cycle, int cycle_len);
91 // Getting transposed matrix
94 // void Transpose(F_type *a, int n, int m);
98 // m - number of columns
100 // a - transposed matrix
104 void Transpose(float *a, int n, int m);
107 // Decision of two dimensional problem generalized distance transform
108 // on the regular grid at all points
109 // min{d2(y' - y) + d4(y' - y)(y' - y) +
110 min(d1(x' - x) + d3(x' - x)(x' - x) + f(x',y'))} (on x', y')
113 // int DistanceTransformTwoDimensionalProblem(const F_type *f,
114 const int n, const int m,
115 const F_type coeff[4],
116 F_type *distanceTransform,
117 int *pointsX, int *pointsY);
119 // f - function on the regular grid
120 // n - number of rows
121 // m - number of columns
122 // coeff - coefficients of optimizable function
123 coeff[0] = d1, coeff[1] = d2,
124 coeff[2] = d3, coeff[3] = d4
126 // distanceTransform - values of generalized distance transform
127 // pointsX - arguments x' that correspond to the optimal value
128 // pointsY - arguments y' that correspond to the optimal value
132 int DistanceTransformTwoDimensionalProblem(const float *f,
133 const int n, const int m,
134 const float coeff[4],
135 float *distanceTransform,
136 int *pointsX, int *pointsY);