8 #include <ldpk/ldpk_power_ct.h> 33 mutable int _k_max_iter;
35 void check_range(
int i)
const 37 if((i < 0) || (i >= N))
49 for(
int i = 0;i < N;++i)
78 {
return _n_max_iter; }
82 {
return _n_post_iter; }
88 double q(1.0),r2 = r_dn * r_dn;
91 for(
int i = 0;i < N;++i)
92 { q += _c[i] * r2pow[i + 1]; }
98 double p = q - ((*this)(q) - q);
102 for(
int i = 0;i < _n_max_iter;++i)
104 double q_iter = (*this)(p);
107 double diff = ::fabs(q_iter - q);
112 for(
int i = 0;i < _n_post_iter;++i)
114 double q_iter = (*this)(p);
118 if(_k_iter > _k_max_iter)
119 { _k_max_iter = _k_iter; }
127 for(_k_iter = 0;_k_iter < _n_max_iter;++_k_iter)
131 double q_cmp = (*this)(p);
132 p += (q - q_cmp) / g;
133 if(::fabs(q - q_cmp) < _epsilon)
137 for(
int i = 0;i < _n_post_iter;++i)
141 double q_cmp = (*this)(p);
142 p += (q - q_cmp) / g;
145 if(_k_iter > _k_max_iter)
146 { _k_max_iter = _k_iter; }
154 double r2 = r_dn * r_dn;
157 double qa(1.0),qb(0.0);
158 for(
int i = 0;i < N;++i)
160 qa += _c[i] * r2pow[i + 1];
161 qb += _c[i] * (2 * i + 2) * r2pow[i];
165 std::ostream& out(std::ostream& cout)
const 167 int p = cout.precision();
169 for(
int i = 0;i < N;++i)
170 { cout <<
" C(" << 2 * i + 2 <<
"): " << std::right << std::fixed << _c[i] <<
"\n"; }
double map_inverse(double q) const
Inverse mapping by solving the fixed point equation without providing initial values.
Definition: ldpk_generic_radial_distortion_1d.h:96
void set_coeff(int i, double q)
Set coefficient c[i], 0 <= i < N.
Definition: ldpk_generic_radial_distortion_1d.h:59
Exception classes for ldpk.
Some index was out of range.
Definition: ldpk_error.h:30
int get_n_max_iter() const
User-defined maximum number of iterations applied in map_inverse in order to fulfill the termination ...
Definition: ldpk_generic_radial_distortion_1d.h:77
int get_k_iter() const
Number of iterations until epsilon was reached. This value is reset at the beginning of each iterativ...
Definition: ldpk_generic_radial_distortion_1d.h:69
A polynomial model with N coefficients for radially symmetric lenses. This class contains the model f...
Definition: ldpk_generic_radial_distortion_1d.h:18
The namespace of (most of the) things related to the Lens Distortion Plugin Kit.
Definition: ldpk.h:19
int get_n_post_iter() const
User-defined number of additional iterations to be applied when the termination condition is fulfille...
Definition: ldpk_generic_radial_distortion_1d.h:81
double operator()(double r_dn) const
Remove distortion. r_dn is a point (distance from center) in diagonally normalized coordinates...
Definition: ldpk_generic_radial_distortion_1d.h:84
Computing N powers of a given number, where N is a compile-time constant.
Definition: ldpk_power_ct.h:33
double jacobi(double r_dn) const
Jacobian. For the pure radial polynomial it's simply the derivative.
Definition: ldpk_generic_radial_distortion_1d.h:150
void reset_k_max_iter()
Reset k_max_iter for debugging purposes.
Definition: ldpk_generic_radial_distortion_1d.h:65
int get_k_max_iter() const
By this value you can check how much iterations per pixel were required to warp an entire image or se...
Definition: ldpk_generic_radial_distortion_1d.h:73
double get_coeff(int i) const
Get coefficient c[i], 0 <= i < N (i.e. coefficient power r^(2i))
Definition: ldpk_generic_radial_distortion_1d.h:53
double map_inverse(double q, double p_start) const
We expect that usually p_start=q is sufficient as starting value, since coefficients are low...
Definition: ldpk_generic_radial_distortion_1d.h:124