-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinverse_compositional_algorithm.h
125 lines (115 loc) · 4.2 KB
/
inverse_compositional_algorithm.h
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
// This program is free software: you can use, modify and/or redistribute it
// under the terms of the simplified BSD License. You should have received a
// copy of this license along this program. If not, see
// <http://www.opensource.org/licenses/bsd-license.html>.
//
// Copyright (C) 2018, Thibaud Briand <[email protected]>
// Copyright (C) 2015, Javier Sánchez Pérez <[email protected]>
// All rights reserved.
#ifndef INVERSE_COMPOSITIONAL_ALGORITHM
#define INVERSE_COMPOSITIONAL_ALGORITHM
/**
*
* This code implements the 'modified inverse compositional algorithm'.
*
* The 'inverse compositional algorithm' was proposed in
* [1] S. Baker, and I. Matthews. (2004). Lucas-kanade 20 years on: A
* unifying framework. International Journal of Computer Vision,
* 56(3), 221-255.
* [2] S. Baker, R. Gross, I. Matthews, and T. Ishikawa. (2004).
* Lucas-kanade 20 years on: A unifying framework: Part 2.
* International Journal of Computer Vision, 56(3), 221-255.
*
* This implementation is for color images. It calculates the global
* transform between two images. It uses robust error functions and a
* coarse-to-fine strategy for computing large displacements
*
**/
#define QUADRATIC 0
#define TRUNCATED_QUADRATIC 1
#define GEMAN_MCCLURE 2
#define LORENTZIAN 3
#define CHARBONNIER 4
#define MAX_ITER 30
#define LAMBDA_0 80
#define LAMBDA_N 5
#define LAMBDA_RATIO 0.90
#define PRECOMPUTATION_GTG //comment to remove the precomputation of GTG
/**
*
* Derivative of robust error functions
*
*/
double rhop(
double t2, //squared difference of both images
double sigma, //robust threshold
int type //choice of the robust error function
);
/**
*
* Inverse compositional algorithm
* Quadratic version - L2 norm
*
*
**/
void inverse_compositional_algorithm(
double *I1, //first image
double *I2, //second image
double *p, //parameters of the transform (output)
int nparams, //number of parameters of the transform
int nx, //number of columns of the image
int ny, //number of rows of the image
int nz, //number of channels of the images
double TOL, //tolerance used for the convergence in the iterations
int nanifoutside, //parameter for discarding boundary pixels
int delta, //distance to the boundary
int type_gradient, //type of gradient
int verbose=0 //enable verbose mode
);
/**
*
* Inverse compositional algorithm
* Version with robust error functions
*
**/
void robust_inverse_compositional_algorithm(
double *I1, //first image
double *I2, //second image
double *p, //parameters of the transform (output)
int nparams, //number of parameters of the transform
int nx, //number of columns of the image
int ny, //number of rows of the image
int nz, //number of channels of the images
double TOL, //Tolerance used for the convergence in the iterations
int robust, //robust error function
double lambda, //parameter of robust error function
int nanifoutside, //parameter for discarding boundary pixels
int delta, //distance to the boundary
int type_gradient, //type of gradient
int verbose=0 //enable verbose mode
);
/**
*
* Multiscale approach for computing the optical flow
*
**/
void pyramidal_inverse_compositional_algorithm(
double *I1, //first image
double *I2, //second image
double *p, //parameters of the transform
int nparams, //number of parameters
int nxx, //image width
int nyy, //image height
int nzz, //number of color channels in image
int nscales, //number of scales
double nu, //downsampling factor
double TOL, //stopping criterion threshold
int robust, //robust error function
double lambda, //parameter of robust error function
int first_scale, //number of the first scale
int nanifoutside, //parameter for discarding boundary pixels
int delta, //distance to the boundary
int type_gradient, //type of gradient
bool verbose //switch on messages
);
#endif