12 template <
class VEC2,
class MAT2>
17 typedef VEC2 vec2_type;
18 typedef MAT2 mat2_type;
33 _c2 = _u2 = _v2 = 0.0;
51 bool check_domain(
const vec2_type& p_dn)
const 58 double disc = 1.0 - 2.0 * _c2 * r2;
73 double disc = 1.0 - 2.0 * _c2 * r2;
79 return vec2_type(0,0);
82 double q = ::sqrt(disc);
84 + (r2 + 2.0 * x2) * _u2
88 + (r2 + 2.0 * y2) * _v2
91 return vec2_type(x_dn,y_dn);
94 mat2_type
jacobi(
const vec2_type& p_dn)
const 103 double u2x = _u2 * x;
104 double v2y = _v2 * y;
105 double u2y = _u2 * y;
106 double v2x = _v2 * x;
107 double c2xy = _c2 * xy;
109 double q = 1.0 - 2.0 * _c2 * r2;
110 mat2_type m_radial = (mat2_type(q) + 2.0 * _c2 *
tensq(p_dn)) / (::sqrt(q) * q);
111 mat2_type m_decenter( 6.0 * u2x + 2.0 * v2y,
114 6.0 * v2y + 2.0 * u2x);
115 return m_radial + m_decenter;
119 void derive(
double* dg,
int n_parameters,
const vec2_type& p_dn)
const 121 int size = 2 * n_parameters;
124 double x2 = p_dn[0] * p_dn[0];
125 double y2 = p_dn[1] * p_dn[1];
126 double xy = p_dn[0] * p_dn[1];
131 double q = 1.0 - 2.0 * _c2 * r2;
132 dg[k++] = x * (-2.0 * r2) / (::sqrt(q) * q);
133 dg[k++] = y * (-2.0 * r2) / (::sqrt(q) * q);
134 if(k == size)
return;
136 dg[k++] = r2 + 2.0 * x2;
138 if(k == size)
return;
141 dg[k++] = r2 + 2.0 * y2;
142 if(k == size)
return;
144 std::cerr <<
"radial_homomorphic_decentered_distortion: n_parameters out of range" << std::endl;
146 std::ostream&
out(std::ostream& cout)
const 148 int p = int(cout.precision());
150 cout <<
"c2: " << _c2 << std::endl;
151 cout <<
"u2: " << _u2 << std::endl;
152 cout <<
"v2: " << _v2 << std::endl;
mat2d tensq(const vec2d &a)
Tensor (dyadic) product square.
Definition: ldpk_vec2d.h:186
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 c[i], 0 <= i < 3.
Definition: ldpk_radial_homomorphic_decentered_distortion.h:42
The homomorphic radially symmetric model of degree 2 with decentering.
Definition: ldpk_radial_homomorphic_decentered_distortion.h:13
void check_range(int i) const
A derived class may check if the index is valid.
Definition: ldpk_generic_distortion_base.h:36
void derive(double *dg, int n_parameters, const vec2_type &p_dn) const
Derivative wrt distortion coefficients. dg points to an array with N / 2 Elements.
Definition: ldpk_radial_homomorphic_decentered_distortion.h:119
The namespace of (most of the) things related to the Lens Distortion Plugin Kit.
Definition: ldpk.h:19
Base class for distortion models.
mat2_type jacobi(const vec2_type &p_dn) const
Analytic version of the Jacobi-matrix.
Definition: ldpk_radial_homomorphic_decentered_distortion.h:94
vec2_type operator()(const vec2_type &p_dn) const
Remove distortion. p_dn is a point in diagonally normalized coordinates.
Definition: ldpk_radial_homomorphic_decentered_distortion.h:64
std::ostream & out(std::ostream &cout) const
The derived class implements a method for printing values inside 3DE4's matrix tool dialog...
Definition: ldpk_radial_homomorphic_decentered_distortion.h:146
double get_coeff(int i) const
Get coefficient c[i], 0 <= i < 3.
Definition: ldpk_radial_homomorphic_decentered_distortion.h:36