![]() |
Lens distortion correction division model 1p
|
Functions for lens distortion model basic operations. More...
#include <stdio.h>
#include <math.h>
#include "lens_distortion.h"
#include "../ami_utilities/utilities.h"
#include "../ami_pol/ami_pol.h"
Functions | |
AMI_DLL_CPP 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_CPP 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_CPP int | ami_lens_distortion_model_update_2v (double *a, int k1, int k2, double **pol) |
AMI_DLL_CPP 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_CPP 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_CPP double | ami_determinante (double **A, int N) |
Function to evaluate the determinant of a matrix. More... | |
AMI_DLL_CPP double | ami_determinante (double A[3][3]) |
AMI_DLL_CPP 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_CPP 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_CPP 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_CPP 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_CPP void | ami_2v_polynom_multiplication (double **pt1, int N1, double **pt2, int N2, double **pt3) |
Function to multiply polinoms of 2 variables. More... | |
AMI_DLL_CPP int | ami_RootCubicPolynomial (double *a, int N, double *x) |
Function to compute the real roots of a cubic polynomial. More... | |
AMI_DLL_CPP double | ami_polynomial_evaluation (double *a, int Na, double x) |
Evaluation of a polynom using horner algorithm. More... | |
AMI_DLL_CPP 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_CPP int | ami_lens_distortion_model_update (double *a, int k, double *pol) |
AMI_DLL_CPP 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_CPP 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_CPP 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_CPP 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. More... | |
AMI_DLL_CPP 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. More... | |
AMI_DLL_CPP 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_CPP double | ami_inverse_lens_distortion_newton_raphson (double x, double y, double x0, double y0, double *xt, double *yt, double *a, int Na) |
AMI_DLL_CPP 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_CPP int | ami_inverse_lens_distortion_fast (double x, double y, double x0, double y0, double *xt, double *yt, double *a, int Na, double dl1r) |
AMI_DLL_CPP int | ami_inverse_lens_distortion_old (double x, double y, double x0, double y0, double *xt, double *yt, double *a, int Na) |
AMI_DLL_CPP 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_CPP 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... | |
Functions for lens distortion model basic operations.
double * ami_1v_polynom_multiplication | ( | double * | pt1, |
int | N1, | ||
double * | pt2, | ||
int | N2, | ||
double * | pt3 | ||
) |
Function to multiply polinoms of 1 variable.
[in] | pt1 | POLYNOM 1 |
[in] | N1 | Degree of polynom 1 |
[in] | pt2 | POLYNOM 2 |
[in] | N2 | Degree of polynom 2 |
[out] | pt3 | Output polynom |
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 .
[in] | p | Original polynom |
[in] | N | Degree of the original polybom |
[out] | p_x | Derivative of the polynom with respect to the first variable |
[out] | p_y | Derivative of the polynom with respect to the second variable |
double ami_2v_polynom_evaluation | ( | double ** | pt1, |
int | N1, | ||
double | x, | ||
double | y | ||
) |
Function to evaluate a 2 variable polynom in one point.
[in] | pt1 | 2 variable polynom |
[in] | N1 | Degree of polynom 1 |
[in] | x,y | Point coordinate where the polynom will be evaluated |
void ami_2v_polynom_multiplication | ( | double ** | pt1, |
int | N1, | ||
double ** | pt2, | ||
int | N2, | ||
double ** | pt3 | ||
) |
Function to multiply polinoms of 2 variables.
[in] | pt1 | POLYNOM 1 |
[in] | N1 | Degree of polynom 1 |
[in] | pt2 | POLYNOM 2 |
[in] | N2 | Degree of polynom 2 |
pt3 | Output polynom |
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.
[in] | pt1 | 2 variable polynom |
[in] | N1 | Degree of polynom 1 |
[out] | p3 | Output 1 variable polynom |
[in] | z | Point where the 2 variable polynom is going to be evaluated |
[in] | flat | Variable where the polynom is going to be evaluated |
double ami_determinante | ( | double ** | A, |
int | N | ||
) |
Function to evaluate the determinant of a matrix.
[in] | A | Matrix |
[in] | N | Degree of A matrix |
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.
[in] | xc2,yc2 | DISTORTION CENTER (THE CENTER OF THE IMAGE) |
[in] | x,y | LINE POINT INFORMATION |
[in] | Nl | NUMBER OF LINES |
[in] | Np | INPUT NUMBER OF POINTS IN EACH LINE |
[out] | a | OUTPUT POLINOMIAL DISTORTION MODEL |
[out] | Na | OUTPUT DEGREE OF POLINOMIAL DISTORTION MODEL (Na=4) return AVERAGE ERROR |
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.
[in] | x,y | Point to inverse |
[in] | x0,y0 | Center of the image |
[out] | xt,yt | Inverve point transformed |
[in] | a | Lens distortion model polynom |
[in] | Na | Degree of the lens distortion model polynom |
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.
[out] | x,y | Original coleccion of lines distribution |
[in] | Nl | Number of lines |
[in] | Np | Number of points for each line |
[in] | x0,y0 | Center of the image |
[out] | a | Lens Distortion Polynomial model |
[in] | Na | Degree of Polynomial model |
[in] | k | Coeficient of the lens distortion polynom model to be updated |
[in] | alfa | Weight for minimizing the square of the distance bewteen distorted and undistorted points |
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.
[out] | x,y | Distorted line coordinates |
[out] | Np | Number of points |
[in] | x0,y0 | Coordinates of the image center |
[in] | a | Polynomial defining the lens distortion model |
[in] | Na | Degree of polynomial model for lens distortion |
[in] | k1 | Coeficient 1 of the polynomial to be updated |
[in] | k2 | Coeficient 2 of the polynomial to be updated |
[in] | alfa | Weight of the distance in the polynom energy |
Nl | Not described. |
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.
[in] | a | INPUT POLINOMIAL DISTORTION MODEL |
[in] | Na | INPUT DEGREE OF POLINOMIAL DISTORTION MODEL |
[in] | xc,yc | INPUT CENTER OF DISTORTION |
[in] | x_input,y_input | INPUT POINT |
[out] | x_output,y_output | OUTPUT UNDISTORTED POINT |
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.
[in] | x,y | Distorted line coordinates |
[in] | Np | Number of points |
[in] | a | Polynomial defining the lens distortion model |
[in] | Na | Degree of polynomial model for lens distortion |
[in] | x0,y0 | Coordinates of the image center |
[in] | k | Coeficient of the polynomial to be updated |
pol | 4 degree polynom to minimize |
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.
[in] | x,y | Distorted line coordinates |
[in] | Np | Number of points |
[in] | a | Polynomial defining the lens distortion model |
[in] | Na | Degree of polynomial model for lens distortion |
[in] | x0,y0 | Coordinates of the image center |
[in] | k1 | Coeficient 1 of the polynomial to be updated |
[in] | k2 | Coeficient 2 of the polynomial to be updated |
pol | 4 degree 2 variable polynom to minimize |
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.
[in] | x,y | Distorted line coordinates |
[in] | Np | Number of points |
[in] | a | Polynomial defining the lens distortion model |
[in] | Na | Degree of polynomial model for lens distortion |
[in] | x0,y0 | Coordinates of the image center |
[in] | k1 | Coeficient 1 of the polynomial to be updated |
[in] | k2 | Coeficient 2 of the polynomial to be updated |
pol | 4 degree 2 variable polynom to minimize | |
[in] | alfa | Weight of the distance in the polynom energy |
void ami_lens_distortion_zoom_normalization | ( | double ** | x, |
double ** | y, | ||
int | Nl, | ||
int * | Np, | ||
double | x0, | ||
double | y0, | ||
double * | a, | ||
int | Na | ||
) |
Not described.
x | Not described |
y | Not described |
Nl | Not described |
Np | Not described |
x0 | Not described |
y0 | Not described |
a | Not described |
Na | Not described |
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.
[in] | x,y | Original point distribution |
[in] | Np | Number of points |
[in] | x0,y0 | Center of the image |
[in] | a | Lens Distortion Polynomial model |
[in] | Na | Degree of polynomial model |
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.
[in] | x,y | Original point distribution |
[in] | Np | Number of points |
[in] | x0,y0 | Center of the image |
[in] | a | Lens Distortion Polynomial model |
[in] | Na | Degree of polynomial model |
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.
[in] | a | INPUT POLINOMIAL DISTORTION MODEL |
[in] | Na | INPUT POLINOMIAL DISTORTION MODEL DEGREE |
[in] | xc,yc | INPUT CENTER OF THE DISTORTION MODEL |
[in] | x,y | INPUT POINTS COORDINATES |
[in] | N | INPUT NUMBER OF POINTS |
[out] | line | OUTPUT LINE EQUATION return AVERAGE ERROR |
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.
[in] | a | INPUT POLINOMIAL DISTORTION MODEL |
[in] | Na | INPUT POLINOMIAL DISTORTION MODEL DEGREE |
[in] | xc,yc | INPUT CENTER OF THE DISTORTION MODEL |
[in] | x,y | INPUT POINTS COORDINATES |
Np | INPUT/OUTPUT NUMBER OF POINTS OF THE LINE | |
[out] | line | OUTPUT LINE EQUATION |
[in] | outlier_elimination_factor | INPUT WE ELIMINATE POINTS SUCH THAT THE DISTANCE TO THE LINE BE BIGGER THAN THE AVERAGE DISTANCE + outlier_elimination_factor*STANDARD DEVIATION return AVERAGE ERROR |
void ami_polynom_determinant | ( | double | p[6][6][19], |
int | Np, | ||
int | Nd, | ||
double * | q | ||
) |
Function to compute the determinant of a polynom matrix.
[in] | p | |
[in] | Np | |
[in] | Nd | |
[out] | q |
double ami_polynomial_evaluation | ( | double * | a, |
int | Na, | ||
double | x | ||
) |
Evaluation of a polynom using horner algorithm.
[in] | a | Polinomial coeficients a[0]+a[1]x+a[2]x^2 +... |
[in] | Na | Polynom degree |
[in] | x | Point where the polynom is evaluated |
int ami_RootCubicPolynomial | ( | double * | a, |
int | N, | ||
double * | x | ||
) |
Function to compute the real roots of a cubic polynomial.
[in] | a | POLINOMIAL COEFICIENTS a[0]+a[1]x+a[2]x^2 +... |
[in] | N | Degree of polinomial (it has to be 3) |
[out] | x | Polinomial roots |