1 #ifndef ldpk_classic_3de_mixed_distortion_sdv 2 #define ldpk_classic_3de_mixed_distortion_sdv 12 template <
class VEC2,
class MAT2>
16 typedef VEC2 vec2_type;
17 typedef MAT2 mat2_type;
23 double _ld,_sq,_cx,_cy,_qu;
27 mutable double _cxx,_cxy,_cyx,_cyy,_cxxx,_cxxy,_cxyy,_cyxx,_cyyx,_cyyy;
28 mutable bool _uptodate;
33 _cxy = (_ld + _cx) / _sq;
37 _cxxy = 2.0 * _qu / _sq;
52 { _c[i] = q;_uptodate =
false; }
57 if(!_uptodate) update();
58 double p0_2 = p[0] * p[0];
59 double p1_2 = p[1] * p[1];
60 double p0_4 = p0_2 * p0_2;
61 double p1_4 = p1_2 * p1_2;
62 double p01_2 = p0_2 * p1_2;
65 q[0] = p[0] * (1 + _cxx * p0_2 + _cxy * p1_2 + _cxxx * p0_4 + _cxxy * p01_2 + _cxyy * p1_4);
66 q[1] = p[1] * (1 + _cyx * p0_2 + _cyy * p1_2 + _cyxx * p0_4 + _cyyx * p01_2 + _cyyy * p1_4);
70 mat2_type
jacobi(
const vec2_type& p_dn)
const 72 if(!_uptodate) update();
73 double x = p_dn[0],x2 = x * x,x3 = x2 * x,x4 = x2 * x2;
74 double y = p_dn[1],y2 = y * y,y3 = y2 * y,y4 = y2 * y2;
76 m[0][0] = 1.0 + x2 * 3.0 * _cxx + y2 * _cxy
77 + x4 * 5.0 * _cxxx + x2 * y2 * 3.0 * _cxxy + y4 * _cxyy;
78 m[1][1] = 1.0 + x2 * _cyx + y2 * 3.0 * _cyy
79 + x4 * _cyxx + x2 * y2 * 3.0 * _cyyx + y4 * 5.0 * _cyyy;
80 m[0][1] = x * y * 2.0 * _cxy + x3 * y * 2.0 * _cxxy + x * y3 * 4.0 * _cxyy;
81 m[1][0] = x * y * 2.0 * _cyx + x3 * y * 4.0 * _cyxx + x * y3 * 2.0 * _cyyx;
84 std::ostream&
out(std::ostream& cout)
const 86 int p = int(cout.precision());
88 cout <<
" Distortion: " << std::right << std::fixed << _ld <<
"\n";
89 cout <<
"Anamorphic Squeeze: " << std::right << std::fixed << _sq <<
"\n";
90 cout <<
" Curvature X: " << std::right << std::fixed << _cx <<
"\n";
91 cout <<
" Curvature Y: " << std::right << std::fixed << _cy <<
"\n";
92 cout <<
"Quartic Distortion: " << std::right << std::fixed << _qu <<
"\n";
Base class for a distortion model with N parameters. You may find it useful to derive your own distor...
Definition: ldpk_generic_distortion_base.h:20
void set_coeff(int i, double q)
Set coefficient as demanded by base class.
Definition: ldpk_classic_3de_mixed_distortion.h:51
The namespace of (most of the) things related to the Lens Distortion Plugin Kit.
Definition: ldpk.h:19
Base class for distortion models.
Degree-2 anamorphic and degree-4 radial mixed model.
Definition: ldpk_classic_3de_mixed_distortion.h:13
std::ostream & out(std::ostream &cout) const
The derived class implements a method for printing values inside 3DE4's matrix tool dialog...
Definition: ldpk_classic_3de_mixed_distortion.h:84
double get_coeff(int i) const
Get coefficient as demanded by base class.
Definition: ldpk_classic_3de_mixed_distortion.h:48
mat2_type jacobi(const vec2_type &p_dn) const
Jacobi-Matrix. The result is a matrix g_{ij} = d/dp_j f(p)_i, where f represents the undistort-functi...
Definition: ldpk_classic_3de_mixed_distortion.h:70
vec2_type operator()(const vec2_type &p) const
Remove distortion. p is a point in diagonally normalized coordinates.
Definition: ldpk_classic_3de_mixed_distortion.h:55