Lens distortion correction division model 1p
 All Classes Files Functions Variables
lens_distortion.h File Reference

Functions for lens distortion model basic operations. More...

Go to the source code of this file.

Functions

AMI_DLL_H double ami_points_to_line_equation_outlier_elimination (double *a, int Na, double xc, double yc, double *x, double *y, int *N, double line[3], double outlier_elimination_factor)
 COMPUTES THE LINE WITH THE BEST FIT TO A SET OF 2D POINTS AND ERASE DISTANT POINTS TAKING INTO ACCOUNT THE DISTORTION MODEL. More...
 
AMI_DLL_H double ami_points_to_line_equation (double *a, int Na, double xc, double yc, double *x, double *y, int N, double line[3])
 COMPUTATION OF THE LINE EQUATION INCLUDING THE POLINOMIAL DISTORTION MODEL. More...
 
AMI_DLL_H double ami_distortion_model_estimation_2p (double xc, double yc, double **x, double **y, int Nl, int *Np, double **a, int *Na)
 DISTORTION MODEL ESTIMATION FROM A SET OF LINES. More...
 
AMI_DLL_H void ami_lens_distortion_model_evaluation (double *a, int Na, double xc, double yc, double x_input, double y_input, double *x_output, double *y_output)
 COMPUTE THE LENS DISTORTION MODEL IN A POINT. More...
 
AMI_DLL_H int ami_lens_distortion_polynomial_update_distance_2v (double *x, double *y, int Np, double *a, int Na, double x0, double y0, int k1, int k2, double **pol, double alfa)
 Function to add the information of a line point sequence to the 4 degree polynomial to compute the lens distortion model. More...
 
AMI_DLL_H double ami_lens_distortion_estimation_2v (double **x, double **y, int Nl, int *Np, double x0, double y0, double *a, int Na, int k1, int k2, double alfa)
 Update of the lens distortion polynomial model for 2 variables. If alfa>0 we adapt a[0] to minimize the square distance beewten distorted and undistorted points and we add a term to the polynomial also minimizing such distance with weight alfa. More...
 
AMI_DLL_H int ami_lens_distortion_model_update_2v (double *a, int k1, int k2, double **pol)
 
AMI_DLL_H int ami_lens_distortion_polynomial_update_2v (double *x, double *y, int Np, double *a, int Na, double x0, double y0, int k1, int k2, double **pol)
 Function to add the information of a line point sequence to the 4 degree polynomial to compute the lens distortion model. More...
 
AMI_DLL_H void ami_2v_polynom_derivatives (double **p, int N, double **p_x, double **p_y)
 Function to compute the partial derivatives of a 2 variable polynom the degree of the derivative polynoms is assumed to be the same that the original one . More...
 
AMI_DLL_H double ami_determinante (double **A, int N)
 Function to evaluate the determinant of a matrix. More...
 
AMI_DLL_H double ami_determinante (double A[3][3])
 
AMI_DLL_H void ami_polynom_determinant (double p[6][6][19], int Np, int Nd, double *q)
 Function to compute the determinant of a polynom matrix. More...
 
AMI_DLL_H double ami_2v_polynom_evaluation (double **pt1, int N1, double x, double y)
 Function to evaluate a 2 variable polynom in one point. More...
 
AMI_DLL_H void ami_2v_polynom_to_1v_polynom (double **pt1, int N1, double *p3, double z, int flat)
 Function to evaluate a 2 variable polynom in one of the variable value. More...
 
AMI_DLL_H double * ami_1v_polynom_multiplication (double *pt1, int N1, double *pt2, int N2, double *pt3)
 Function to multiply polinoms of 1 variable. More...
 
AMI_DLL_H void ami_2v_polynom_multiplication (double **pt1, int N1, double **p2, int N2, double **p3)
 Function to multiply polinoms of 2 variables. More...
 
AMI_DLL_H int ami_RootCubicPolynomial (double *a, int N, double *x)
 Function to compute the real roots of a cubic polynomial. More...
 
AMI_DLL_H double ami_polynomial_evaluation (double *a, int Na, double x)
 Evaluation of a polynom using horner algorithm. More...
 
AMI_DLL_H int ami_lens_distortion_polynomial_update (double *x, double *y, int Np, double *a, int Na, double x0, double y0, int k, double *pol)
 Function to add the information of a line point sequence to the 4 degree polynomial to compute the lens distortion model. More...
 
AMI_DLL_H int ami_lens_distortion_model_update (double *a, int k, double *pol)
 
AMI_DLL_H double ami_LensDistortionVarianceError (double *x, double *y, int Np, double x0, double y0, double *a, int Na)
 Function to compute the lens distortion energy error (the residual variance of the point distribution. More...
 
AMI_DLL_H double ami_LensDistortionEnergyError (double *x, double *y, int Np, double x0, double y0, double *a, int Na)
 Function to compute the lens distortion energy error. More...
 
AMI_DLL_H int ami_inverse_lens_distortion (double x, double y, double x0, double y0, double *xt, double *yt, double *a, int Na)
 Function to inverse the lens distortion transformation. More...
 
AMI_DLL_H double ami_lens_distortion_estimation (double **x, double **y, int Nl, int *Np, double x0, double y0, double *a, int Na, int k, double alfa)
 Function to compute the lens distortion model. More...
 
AMI_DLL_H void ami_lens_distortion_zoom_normalization (double **x, double **y, int Nl, int *Np, double x0, double y0, double *a, int Na)
 Not described. More...
 
int ami_inverse_lens_distortion_fast (double x, double y, double x0, double y0, double *xt, double *yt, double *a, int Na, double dl1r)
 
double ami_inverse_lens_distortion_newton_raphson (double x, double y, double x0, double y0, double *xt, double *yt, double *a, int Na)
 

Detailed Description

Functions for lens distortion model basic operations.

Author
Luis Alvarez

Function Documentation

AMI_DLL_H double* ami_1v_polynom_multiplication ( double *  pt1,
int  N1,
double *  pt2,
int  N2,
double *  pt3 
)

Function to multiply polinoms of 1 variable.

Precondition
Any parameter can be null.
Postcondition
The result is added to the output polynom coeficients.
Parameters
[in]pt1POLYNOM 1
[in]N1Degree of polynom 1
[in]pt2POLYNOM 2
[in]N2Degree of polynom 2
[out]pt3Output polynom
Returns
p3
AMI_DLL_H void ami_2v_polynom_derivatives ( double **  p,
int  N,
double **  p_x,
double **  p_y 
)

Function to compute the partial derivatives of a 2 variable polynom the degree of the derivative polynoms is assumed to be the same that the original one .

Precondition
Any parameter can be null.
Parameters
[in]pOriginal polynom
[in]NDegree of the original polybom
[out]p_xDerivative of the polynom with respect to the first variable
[out]p_yDerivative of the polynom with respect to the second variable
AMI_DLL_H double ami_2v_polynom_evaluation ( double **  pt1,
int  N1,
double  x,
double  y 
)

Function to evaluate a 2 variable polynom in one point.

Precondition
Any parameter can be null.
Parameters
[in]pt12 variable polynom
[in]N1Degree of polynom 1
[in]x,yPoint coordinate where the polynom will be evaluated
Returns
Value o evaluation
AMI_DLL_H void ami_2v_polynom_multiplication ( double **  pt1,
int  N1,
double **  pt2,
int  N2,
double **  pt3 
)

Function to multiply polinoms of 2 variables.

Precondition
Any parameter can be null.
Postcondition
The result is added to the output polynom coeficients.
Parameters
[in]pt1POLYNOM 1
[in]N1Degree of polynom 1
[in]pt2POLYNOM 2
[in]N2Degree of polynom 2
pt3Output polynom
AMI_DLL_H void ami_2v_polynom_to_1v_polynom ( double **  pt1,
int  N1,
double *  p3,
double  z,
int  flat 
)

Function to evaluate a 2 variable polynom in one of the variable value.

Precondition
Any parameter can be null.
Postcondition
The output is a 1 degree polynom
Parameters
[in]pt12 variable polynom
[in]N1Degree of polynom 1
[out]p3Output 1 variable polynom
[in]zPoint where the 2 variable polynom is going to be evaluated
[in]flatVariable where the polynom is going to be evaluated
AMI_DLL_H double ami_determinante ( double **  A,
int  N 
)

Function to evaluate the determinant of a matrix.

Precondition
Any parameter can be null.
Parameters
[in]AMatrix
[in]NDegree of A matrix
Returns
Determinant of A
AMI_DLL_H double ami_distortion_model_estimation_2p ( double  xc2,
double  yc2,
double **  x,
double **  y,
int  Nl,
int *  Np,
double **  a,
int *  Na 
)

DISTORTION MODEL ESTIMATION FROM A SET OF LINES.

Precondition
Any parameter can be null.
Parameters
[in]xc2,yc2DISTORTION CENTER (THE CENTER OF THE IMAGE)
[in]x,yLINE POINT INFORMATION
[in]NlNUMBER OF LINES
[in]NpINPUT NUMBER OF POINTS IN EACH LINE
[out]aOUTPUT POLINOMIAL DISTORTION MODEL
[out]NaOUTPUT DEGREE OF POLINOMIAL DISTORTION MODEL (Na=4) return AVERAGE ERROR
Author
Luis Alvarez
AMI_DLL_H int ami_inverse_lens_distortion ( double  x,
double  y,
double  x0,
double  y0,
double *  xt,
double *  yt,
double *  a,
int  Na 
)

Function to inverse the lens distortion transformation.

Precondition
Any parameter can be null.
Na has to be positive.
Parameters
[in]x,yPoint to inverse
[in]x0,y0Center of the image
[out]xt,ytInverve point transformed
[in]aLens distortion model polynom
[in]NaDegree of the lens distortion model polynom
Returns
0
Author
Luis Alvarez
AMI_DLL_H double ami_lens_distortion_estimation ( double **  x,
double **  y,
int  Nl,
int *  Np,
double  x0,
double  y0,
double *  a,
int  Na,
int  k,
double  alfa 
)

Function to compute the lens distortion model.

Precondition
Any parameter can be null.
Na has to be positive.
Parameters
[out]x,yOriginal coleccion of lines distribution
[in]NlNumber of lines
[in]NpNumber of points for each line
[in]x0,y0Center of the image
[out]aLens Distortion Polynomial model
[in]NaDegree of Polynomial model
[in]kCoeficient of the lens distortion polynom model to be updated
[in]alfaWeight for minimizing the square of the distance bewteen distorted and undistorted points
Returns
Error
Author
Luis Alvarez
AMI_DLL_H double ami_lens_distortion_estimation_2v ( double **  x,
double **  y,
int  Nl,
int *  Np,
double  x0,
double  y0,
double *  a,
int  Na,
int  k1,
int  k2,
double  alfa 
)

Update of the lens distortion polynomial model for 2 variables. If alfa>0 we adapt a[0] to minimize the square distance beewten distorted and undistorted points and we add a term to the polynomial also minimizing such distance with weight alfa.

Precondition
Any parameter can be null.
Parameters
[out]x,yDistorted line coordinates
[out]NpNumber of points
[in]x0,y0Coordinates of the image center
[in]aPolynomial defining the lens distortion model
[in]NaDegree of polynomial model for lens distortion
[in]k1Coeficient 1 of the polynomial to be updated
[in]k2Coeficient 2 of the polynomial to be updated
[in]alfaWeight of the distance in the polynom energy
NlNot described.
Returns
Return the distance
AMI_DLL_H void ami_lens_distortion_model_evaluation ( double *  a,
int  Na,
double  xc,
double  yc,
double  x_input,
double  y_input,
double *  x_output,
double *  y_output 
)

COMPUTE THE LENS DISTORTION MODEL IN A POINT.

Precondition
Any parameter can be null.
Na has to be positive.
Parameters
[in]aINPUT POLINOMIAL DISTORTION MODEL
[in]NaINPUT DEGREE OF POLINOMIAL DISTORTION MODEL
[in]xc,ycINPUT CENTER OF DISTORTION
[in]x_input,y_inputINPUT POINT
[out]x_output,y_outputOUTPUT UNDISTORTED POINT
Author
Luis Alvarez
AMI_DLL_H int ami_lens_distortion_polynomial_update ( double *  x,
double *  y,
int  Np,
double *  a,
int  Na,
double  x0,
double  y0,
int  k,
double *  pol 
)

Function to add the information of a line point sequence to the 4 degree polynomial to compute the lens distortion model.

Precondition
Any parameter can be null.
Np and Na have to be positive.
Parameters
[in]x,yDistorted line coordinates
[in]NpNumber of points
[in]aPolynomial defining the lens distortion model
[in]NaDegree of polynomial model for lens distortion
[in]x0,y0Coordinates of the image center
[in]kCoeficient of the polynomial to be updated
pol4 degree polynom to minimize
Returns
0
AMI_DLL_H int ami_lens_distortion_polynomial_update_2v ( double *  x,
double *  y,
int  Np,
double *  a,
int  Na,
double  x0,
double  y0,
int  k1,
int  k2,
double **  pol 
)

Function to add the information of a line point sequence to the 4 degree polynomial to compute the lens distortion model.

Precondition
Any parameter can be null.
Parameters
[in]x,yDistorted line coordinates
[in]NpNumber of points
[in]aPolynomial defining the lens distortion model
[in]NaDegree of polynomial model for lens distortion
[in]x0,y0Coordinates of the image center
[in]k1Coeficient 1 of the polynomial to be updated
[in]k2Coeficient 2 of the polynomial to be updated
pol4 degree 2 variable polynom to minimize
Returns
0
AMI_DLL_H int ami_lens_distortion_polynomial_update_distance_2v ( double *  x,
double *  y,
int  Np,
double *  a,
int  Na,
double  x0,
double  y0,
int  k1,
int  k2,
double **  pol,
double  alfa 
)

Function to add the information of a line point sequence to the 4 degree polynomial to compute the lens distortion model.

Precondition
Any parameter can be null.
Parameters
[in]x,yDistorted line coordinates
[in]NpNumber of points
[in]aPolynomial defining the lens distortion model
[in]NaDegree of polynomial model for lens distortion
[in]x0,y0Coordinates of the image center
[in]k1Coeficient 1 of the polynomial to be updated
[in]k2Coeficient 2 of the polynomial to be updated
pol4 degree 2 variable polynom to minimize
[in]alfaWeight of the distance in the polynom energy
Returns
0
AMI_DLL_H void ami_lens_distortion_zoom_normalization ( double **  x,
double **  y,
int  Nl,
int *  Np,
double  x0,
double  y0,
double *  a,
int  Na 
)

Not described.

Precondition
Any parameter can be null.
.
Author
Luis Alvarez
Parameters
xNot described
yNot described
NlNot described
NpNot described
x0Not described
y0Not described
aNot described
NaNot described
AMI_DLL_H double ami_LensDistortionEnergyError ( double *  x,
double *  y,
int  Np,
double  x0,
double  y0,
double *  a,
int  Na 
)

Function to compute the lens distortion energy error.

Precondition
Any parameter can be null.
Np and Na have to be positive.
Parameters
[in]x,yOriginal point distribution
[in]NpNumber of points
[in]x0,y0Center of the image
[in]aLens Distortion Polynomial model
[in]NaDegree of polynomial model
Returns
The lens distortion energy error
Author
Luis Alvarez
AMI_DLL_H double ami_LensDistortionVarianceError ( double *  x,
double *  y,
int  Np,
double  x0,
double  y0,
double *  a,
int  Na 
)

Function to compute the lens distortion energy error (the residual variance of the point distribution.

Precondition
Any parameter can be null.
Np and Na have to be positive.
Parameters
[in]x,yOriginal point distribution
[in]NpNumber of points
[in]x0,y0Center of the image
[in]aLens Distortion Polynomial model
[in]NaDegree of polynomial model
Returns
The lens distortion energy error
Author
Luis Alvarez
AMI_DLL_H double ami_points_to_line_equation ( double *  a,
int  Na,
double  xc,
double  yc,
double *  x,
double *  y,
int  N,
double  line[3] 
)

COMPUTATION OF THE LINE EQUATION INCLUDING THE POLINOMIAL DISTORTION MODEL.

Precondition
Any parameter can be null.
Parameters
[in]aINPUT POLINOMIAL DISTORTION MODEL
[in]NaINPUT POLINOMIAL DISTORTION MODEL DEGREE
[in]xc,ycINPUT CENTER OF THE DISTORTION MODEL
[in]x,yINPUT POINTS COORDINATES
[in]NINPUT NUMBER OF POINTS
[out]lineOUTPUT LINE EQUATION return AVERAGE ERROR
Author
Luis Alvarez
AMI_DLL_H double ami_points_to_line_equation_outlier_elimination ( double *  a,
int  Na,
double  xc,
double  yc,
double *  x,
double *  y,
int *  Np,
double  line[3],
double  outlier_elimination_factor 
)

COMPUTES THE LINE WITH THE BEST FIT TO A SET OF 2D POINTS AND ERASE DISTANT POINTS TAKING INTO ACCOUNT THE DISTORTION MODEL.

Precondition
Any parameter can be null.
Parameters
[in]aINPUT POLINOMIAL DISTORTION MODEL
[in]NaINPUT POLINOMIAL DISTORTION MODEL DEGREE
[in]xc,ycINPUT CENTER OF THE DISTORTION MODEL
[in]x,yINPUT POINTS COORDINATES
NpINPUT/OUTPUT NUMBER OF POINTS OF THE LINE
[out]lineOUTPUT LINE EQUATION
[in]outlier_elimination_factorINPUT WE ELIMINATE POINTS SUCH THAT THE DISTANCE TO THE LINE BE BIGGER THAN THE AVERAGE DISTANCE + outlier_elimination_factor*STANDARD DEVIATION return AVERAGE ERROR
Author
Luis Alvarez
AMI_DLL_H void ami_polynom_determinant ( double  p[6][6][19],
int  Np,
int  Nd,
double *  q 
)

Function to compute the determinant of a polynom matrix.

Precondition
Any parameter can be null.
Parameters
[in]p
[in]Np
[in]Nd
[out]q
AMI_DLL_H double ami_polynomial_evaluation ( double *  a,
int  Na,
double  x 
)

Evaluation of a polynom using horner algorithm.

Precondition
Any parameter can be null.
Na has to be positive.
Postcondition
It returns the number of roots found sorted by magnitud.
Parameters
[in]aPolinomial coeficients a[0]+a[1]x+a[2]x^2 +...
[in]NaPolynom degree
[in]xPoint where the polynom is evaluated
Returns
Evaluation of x in polynomial a
Author
Luis Alvarez
AMI_DLL_H int ami_RootCubicPolynomial ( double *  a,
int  N,
double *  x 
)

Function to compute the real roots of a cubic polynomial.

Precondition
Any parameter can be null.
N has to be 3.
Postcondition
It returns the number of roots found sorted by magnitud.
Parameters
[in]aPOLINOMIAL COEFICIENTS a[0]+a[1]x+a[2]x^2 +...
[in]NDegree of polinomial (it has to be 3)
[out]xPolinomial roots
Author
Luis Alvarez