algebraic lens distortion
 All Classes Namespaces Files Functions Variables Defines
Functions | Variables
lens_distortion.cpp File Reference
#include "lens_distortion.h"
Include dependency graph for lens_distortion.cpp:

Go to the source code of this file.

Functions

int test_compatibility_lens_distortion_model (double *a, int Na, double max_radius)
 function checks if the lens distortion model is an increasing function in [0,max_radius]
int ami_line2d_calculation (double line[3], double **Points2D, int N)
 function to compute a line equation by minimizing the distance to a point collection
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 alpha)
 function to add the information of a line point sequence to the 4 degree polynomial to compute the lens distortion model
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 alpha, double max_radius)
int ami_lens_distortion_model_update_2v (double *a, int Na, int k1, int k2, double **pol, double max_radius)
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)
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
void ami_polynom_determinant (double p[6][6][19], int Np, int Nd, double *q)
 function to compute the determinant of a polynom matrix
double ami_2v_polynom_evaluation (double **p1, int N1, double x, double y)
 function to evaluate a 2 variable polynom in one point
void ami_2v_polynom_to_1v_polynom (double **p1, int N1, double *p3, double z, int flat)
 function to evaluate a 2 variable polynom in one of the variable value. The output is a 1 degree polynom
double * ami_1v_polynom_multiplication (double *p1, int N1, double *p2, int N2, double *p3)
 function to multiply polinoms of 1 variable. the result is added to the output polynom COEFFICIENTs
void ami_2v_polynom_multiplication (double **p1, int N1, double **p2, int N2, double **p3)
 function to multiply polynoms of 2 variables
int ami_RootCubicPolynomial (double *a, int N, double *x)
 function to compute the real roots of a cubic polynomial. It returns the number of roots found sorted by magnitud
double ami_polynomial_evaluation (double *a, int Na, double x)
 function to evaluate a polynom using the Horner algorithm
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
int ami_lens_distortion_model_update (double *a, int Na, int k, double *pol, double max_radius)
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 (the residual variance of the point distribution
double ami_LensDistortionEnergyError_Vmin (double *x, double *y, int Np, double x0, double y0, double *a, int Na)
 function to compute the lens distortion vmin energy error of the point distribution
double ami_lens_distortion_estimation (double **x, double **y, int Nl, int *Np, double x0, double y0, double *a, int Na, int k, double alpha, double max_radius)
void ami_lens_distortion_zoom_normalization (double **x, double **y, int Nl, int *Np, double *a, int Na)
int calculate_points (double *amin, double **points_2D_modified, int N, int Na, double x0, double y0)
 function to estimate the position of 2D points (pixels) for the actual lens distortion model
double distance_function (double *solution, double **x, double **y, int Nl, int *Np, int Na)
double find_lambda (double lambda1, double lambda2, double lambda3, double f_1, double f_2, double f_3, double *amin_copy, double *amin, double **x, double **y, int Nl, int *Np, int Na, double *grad_f, int *change_k)
double minimize_cuadratic_polynom (double lambda1, double lambda2, double lambda3, double f_1, double f_2, double f_3, double *amin_copy, double *amin, double **x, double **y, int Nl, int *Np, int Na, double *grad_f, int *change_k)
double cuadratic_fitting (double *amin_copy, double *amin, double **x, double **y, int Nl, int *Np, int Na, double lambda1, double lambda2, double lambda3, double f_1, double f_2, double f_3, double *grad_f, int *change_k)
double minimize_lambda (double *amin, double **x, double **y, int Nl, int *Np, int Na, double *grad_f, double f, int *change_k)
double gradient_method (double *solution, double **x, double **y, int Nl, int *Np, int Na, int *change_k, int zoom, int optimize_center)
int optimize (double *solution, double **x, double **y, double **xx, double **yy, int Nl, int *Np, int Na, double factor_n, int zoom, FILE *fp1, int optimize_center)
int algebraic_method_pre_gradient (int Nl, int *Np, double *a, double **x, double **y, double **xx, double **yy, double factor_n, int zoom, FILE *fp1, int optimize_center, double max_radius)
int trivial_solution (int Nl, int *Np, double *a, double **xx, double **yy, double factor_n, FILE *fp1, double *trivial, int optimize_center)
int search_for_best_center (int Nl, int *Np, double *a, double **xx, double **yy, int width, int height, double max_radius)
int read_line_primitives (char filename[300], int *Nl, int **Np, double ***x, double ***y)
 function to read point line primitives
double calculate_factor_n (double **xx, double **yy, int Nl, int *Np, double x0, double y0)
 function to calculate the factor_n, needed for transforming k (lens distortion model) from normalized coordinates to pixels
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.
double ami_inverse_lens_distortion_newton_raphson (double x, double y, double x0, double y0, double *xt, double *yt, double *a, int Na)
 COMPUTE THE INVERSE OF LENS DISTORTION MODEL IN A POINT USING NEWTON-RAPHSON.
int build_l1r_vector (std::vector< double > &l1r, ami::point2d< double > &dc, double max_distance_corner, int Na, double *a)
ami::image< unsigned char > undistort_image_inverse_fast (ami::image< unsigned char > input_image, int Na, double *a, ami::point2d< double > dc, const double &image_amplification_factor)

Variables

int n_iterations = 0
int f_evaluations = 0
double tol_lambda = 1e-8

Function Documentation

int algebraic_method_pre_gradient ( int  Nl,
int *  Np,
double *  a,
double **  x,
double **  y,
double **  xx,
double **  yy,
double  factor_n,
int  zoom,
FILE *  fp1,
int  optimize_center,
double  max_radius 
)
Parameters:
NlNumber of lines
NpNumber of points/line
aLens distortion model polynom
xCoordinates of points (normalized)
yCoordinates of points (normalized)
xxCoordinates of points
yyCoordinates of points
factor_nFactor to normalize coordinates
zoomZoom strategy
fp1Pointer to the output file
optimize_centerTo optimize the center of distortion
max_radiusMAXIMUM RADIAL DISTANCE IN PHOTO

Definition at line 1771 of file lens_distortion.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

double * ami_1v_polynom_multiplication ( double *  p1,
int  N1,
double *  p2,
int  N2,
double *  p3 
)

function to multiply polinoms of 1 variable. the result is added to the output polynom COEFFICIENTs

Author:
Luis Alvarez
Returns:
return the calculation
Parameters:
p1POLYNOM 1 (INPUT)
N1DEGREE OF POLYNOM 1 (INPUT)
p2POLYNOM 2 (INPUT)
N2DEGREE OF POLYNOM 2 (INPUT)
p3OUTPUT POLYNOM (INPUT-OUTPUT)

Definition at line 744 of file lens_distortion.cpp.

Here is the caller graph for this function:

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

Author:
Luis Alvarez
Returns:
return void
Parameters:
pORIGINAL POLYNOM (INPUT)
NDEGREE OF THE ORIGINAL POLYNOM (INPUT)
p_xDERIVATIVE OF THE POLYNOM WITH RESPECT TO THE FIRST VARIABLE (OUTPUT)
p_yDERIVATIVE OF THE POLYNOM WITH RESPECT TO THE SECOND VARIABLE(OUTPUT)

Definition at line 600 of file lens_distortion.cpp.

Here is the caller graph for this function:

double ami_2v_polynom_evaluation ( double **  p1,
int  N1,
double  x,
double  y 
)

function to evaluate a 2 variable polynom in one point

Author:
Luis Alvarez
Returns:
return the evaluation
Parameters:
p12 VARIABLE POLYNOM (INPUT)
N1DEGREE OF POLYNOM 1 (INPUT)
yPOINT COORDINATE WHERE THE POLYNOM WILL BE EVALUATED (INPUT)

Definition at line 676 of file lens_distortion.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void ami_2v_polynom_multiplication ( double **  p1,
int  N1,
double **  p2,
int  N2,
double **  p3 
)

function to multiply polynoms of 2 variables

Author:
Luis Alvarez
Returns:
return void
Parameters:
p1POLYNOM 1 (INPUT)
N1DEGREE OF POLYNOM 1 (INPUT)
p2POLYNOM 2 (INPUT)
N2DEGREE OF POLYNOM 2 (INPUT)
p3OUTPUT POLYNOM (INPUT - OUTPUT)

Definition at line 771 of file lens_distortion.cpp.

Here is the caller graph for this function:

void ami_2v_polynom_to_1v_polynom ( double **  p1,
int  N1,
double *  p3,
double  z,
int  flat 
)

function to evaluate a 2 variable polynom in one of the variable value. The output is a 1 degree polynom

VARIABLE WHERE THE POLYNOM IS GOING TO BE EVALUATED

Author:
Luis Alvarez
Returns:
return void
Parameters:
p12 VARIABLE POLYNOM (INPUT)
N1DEGREE OF POLYNOM 1 (INPUT)
p3OUTPUT 1 VARIABLE POLYNOM (OUTPUT)
zPOINT WHERE THE 2 VARIABLE POLYNOM IS GOING TO BE EVALUATED

Definition at line 708 of file lens_distortion.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

double ami_inverse_lens_distortion_newton_raphson ( double  x,
double  y,
double  x0,
double  y0,
double *  xt,
double *  yt,
double *  a,
int  Na 
)

COMPUTE THE INVERSE OF LENS DISTORTION MODEL IN A POINT USING NEWTON-RAPHSON.

Parameters:
[in]x,yPOINT TO INVERSE (INPUT)
[in]x0,y0LENS DISTORTION MODEL CENTER (INPUT)
[out]*xt,*ytUNDISTORTED POINT (INVERSE POINT TRANSFORMED) (OUTPUT)
[in]*aLENS DISTORTION MODEL COEFFICIENTS
[in]NaDEGREE OF THE LENS DISTORTION MODEL POLYNOM
Author:
Luis Alvarez

Definition at line 2182 of file lens_distortion.cpp.

Here is the call graph for this function:

double ami_lens_distortion_estimation ( double **  x,
double **  y,
int  Nl,
int *  Np,
double  x0,
double  y0,
double *  a,
int  Na,
int  k,
double  alpha,
double  max_radius 
)
Parameters:
yORIGINAL COLECCION OF LINES DISTRIBUTION (INPUT)
NlNUMBER OF LINES
NpNUMBER OF POINTS FOR EACH LINE(INPUT)
y0CENTER OF THE IMAGE (INPUT)
aLens Distortion Polynomial model (INPUT-OUTPUT)
NaDegree of Polynomial model (INPUT)
kCOEFFICIENT OF THE LENS DISTORTION POLYNOM MODEL TO BE UPDATED
alphaWEIGHT FOR MINIMIZING THE SQUARE OF THE DISTANCE BETWEEN DISTORTED AND UNDISTORTED POINTS
max_radiusMAX RADIUS TO CHECK THE COMPATIBILITY CRITERIUM OF LENS DISTORTION *

Definition at line 1149 of file lens_distortion.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

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  alpha,
double  max_radius 
)
Parameters:
yDISTORTED LINE COORDINATES (INPUT)
NlNUMBER OF LINES (RECTS)
NpNUMBER OF POINTS (INPUT)
y0COORDINATES OF THE IMAGE CENTER
aPOLYNOMIAL DEFINING THE LENS DISTORTION MODEL (INPUT)
NaDEGREE OF POLYNOMIAL MODEL FOR LENS DISTORTION
k1COEFFICIENT 1 OF THE POLYNOMIAL TO BE UPDATED
k2COEFFICIENT 2 OF THE POLYNOMIAL TO BE UPDATED
alphaWEIGHT OF THE DISTANCE IN THE POLYNOM ENERGY
max_radiusMAXIMUM RADIAL DISTANCE IN PHOTO

Definition at line 289 of file lens_distortion.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

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 POLYNOMIAL DISTORTION MODEL
[in]NaINPUT DEGREE OF POLYNOMIAL DISTORTION MODEL
[in]xc,ycINPUT CENTER OF DISTORTION
[in]x_input,y_inputINPUT POINT
[out]x_output,y_outputOUTPUT UNDISTORTED POINT
Author:
Luis Alvarez

Definition at line 2156 of file lens_distortion.cpp.

Here is the call graph for this function:

int ami_lens_distortion_model_update ( double *  a,
int  Na,
int  k,
double *  pol,
double  max_radius 
)
Parameters:
aPOLYNOMIAL DEFINING THE LENS DISTORTION MODEL (INPUT-OUTPUT)
NaDEGREE OF POLYNOMIAL MODEL FOR LENS DISTORTION (INPUT)
kCOEFFICIENT OF THE POLYNOMIAL TO BE UPDATED (INPUT)
pol4 DEGREE POLYNOM TO MINIMIZE (INPUT)
max_radiusMAX RADIUS TO CHECK THE COMPATIBILITY CRITERIUM OF LENS DISTORTION *

Definition at line 982 of file lens_distortion.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int ami_lens_distortion_model_update_2v ( double *  a,
int  Na,
int  k1,
int  k2,
double **  pol,
double  max_radius 
)
Parameters:
aPOLYNOMIAL DEFINING THE LENS DISTORTION MODEL (INPUT-OUTPUT)
NaDEGREE OF POLYNOMIAL MODEL FOR LENS DISTORTION (INPUT)
k1COEFFICIENT 1 OF THE POLYNOMIAL TO BE UPDATED (INPUT)
k2COEFFICIENT 2 OF THE POLYNOMIAL TO BE UPDATED (INPUT)
pol4 DEGREE POLYNOM TO MINIMIZE (INPUT)
max_radiusMAXIMUM RADIAL DISTANCE IN PHOTO

Definition at line 346 of file lens_distortion.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Author:
Luis Alvarez
Returns:
return 0 if the function finishes properly
Parameters:
yDISTORTED LINE COORDINATES (INPUT)
NpNUMBER OF POINTS (INPUT)
aPOLYNOMIAL DEFINING THE LENS DISTORTION MODEL (INPUT)
NaDEGREE OF POLYNOMIAL MODEL FOR LENS DISTORTION
y0COORDINATES OF THE IMAGE CENTER
kCOEFFICIENT OF THE POLYNOMIAL TO BE UPDATED
pol4 DEGREE POLYNOM TO MINIMIZE (INPUT-OUTPUT)

Definition at line 881 of file lens_distortion.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

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 
)
Parameters:
yDISTORTED LINE COORDINATES (INPUT)
NpNUMBER OF POINTS (INPUT)
aPOLYNOMIAL DEFINING THE LENS DISTORTION MODEL (INPUT)
NaDEGREE OF POLYNOMIAL MODEL FOR LENS DISTORTION
y0COORDINATES OF THE IMAGE CENTER
k1COEFFICIENT 1 OF THE POLYNOMIAL TO BE UPDATED
k2COEFFICIENT 2 OF THE POLYNOMIAL TO BE UPDATED
pol4 DEGREE 2 VARIABLE POLYNOM TO MINIMIZE (INPUT-OUTPUT)

Definition at line 474 of file lens_distortion.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

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  alpha 
)

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

WEIGHT OF THE DISTANCE IN THE POLYNOM ENERGY

Author:
Luis Alvarez
Returns:
return 0 if function finishes properly
Parameters:
yDISTORTED LINE COORDINATES (INPUT)
NpNUMBER OF POINTS (INPUT)
aPOLYNOMIAL DEFINING THE LENS DISTORTION MODEL (INPUT)
NaDEGREE OF POLYNOMIAL MODEL FOR LENS DISTORTION
y0COORDINATES OF THE IMAGE CENTER
k1COEFFICIENT 1 OF THE POLYNOMIAL TO BE UPDATED
k2COEFFICIENT 2 OF THE POLYNOMIAL TO BE UPDATED
pol4 DEGREE 2 VARIABLE POLYNOM TO MINIMIZE (INPUT-OUTPUT)

Definition at line 203 of file lens_distortion.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void ami_lens_distortion_zoom_normalization ( double **  x,
double **  y,
int  Nl,
int *  Np,
double *  a,
int  Na 
)
Parameters:
yORIGINAL COLECCION OF LINES DISTRIBUTION (INPUT)
NlNUMBER OF LINES
NpNUMBER OF POINTS FOR EACH LINE(INPUT)
[in,out]a
NaDegree of Polynomial model (INPUT)

Definition at line 1205 of file lens_distortion.cpp.

Here is the caller graph for this function:

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 (the residual variance of the point distribution

Author:
Luis Alvarez
Returns:
return the evaluation
Parameters:
yORIGINAL POINT DISTRIBUTION (INPUT)
NpNUMBER OF POINTS (INPUT)
y0CENTER OF THE IMAGE (INPUT)
aLens Distortion Polynomial model (INPUT)
NaDegree of Polynomial model (INPUT)

Definition at line 1038 of file lens_distortion.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

double ami_LensDistortionEnergyError_Vmin ( double *  x,
double *  y,
int  Np,
double  x0,
double  y0,
double *  a,
int  Na 
)

function to compute the lens distortion vmin energy error of the point distribution

Author:
Luis Alvarez
Returns:
return the evaluation
Parameters:
yORIGINAL POINT DISTRIBUTION (INPUT)
NpNUMBER OF POINTS (INPUT)
y0CENTER OF THE IMAGE (INPUT)
aLens Distortion Polynomial model (INPUT)
NaDegree of Polynomial model (INPUT)

Definition at line 1093 of file lens_distortion.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int ami_line2d_calculation ( double  line[3],
double **  Points2D,
int  N 
)

function to compute a line equation by minimizing the distance to a point collection

Author:
Luis Alvarez and Luis Gomez
Returns:
return 0 if function finishes properly and !0 otherwise
Parameters:
lineline coefficients (ax+by+c=0)
Points2Dset of 2D points
Nnumber of points

Definition at line 79 of file lens_distortion.cpp.

Here is the caller graph for this function:

void ami_polynom_determinant ( double  p[6][6][19],
int  Np,
int  Nd,
double *  q 
)

function to compute the determinant of a polynom matrix

Author:
Luis Alvarez
Returns:
return void

Definition at line 630 of file lens_distortion.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

double ami_polynomial_evaluation ( double *  a,
int  Na,
double  x 
)

function to evaluate a polynom using the Horner algorithm

Author:
Luis Alvarez
Returns:
return the evaluation
Parameters:
aPOLYNOM COEFFICIENT
NaPOLYNOM DEGREE
xPOINT WHERE THE POLYNOM IS EVALUATED

Definition at line 860 of file lens_distortion.cpp.

Here is the caller graph for this function:

int ami_RootCubicPolynomial ( double *  a,
int  N,
double *  x 
)

function to compute the real roots of a cubic polynomial. It returns the number of roots found sorted by magnitud

Author:
Luis Alvarez
Returns:
return 3 if the function finishes properly
Parameters:
aPOLYNOMIAL COEFFICIENTS a[0]+a[1]x+a[2]x^2 +...
NDEGREE OF POLYNOMIAL (IT HAS TO BE 3)
xPOLYNOMIAL ROOTS

Definition at line 799 of file lens_distortion.cpp.

Here is the caller graph for this function:

int build_l1r_vector ( std::vector< double > &  l1r,
ami::point2d< double > &  dc,
double  max_distance_corner,
int  Na,
double *  a 
)

Definition at line 2243 of file lens_distortion.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

double calculate_factor_n ( double **  x,
double **  y,
int  Nl,
int *  Np,
double  x0,
double  y0 
)

function to calculate the factor_n, needed for transforming k (lens distortion model) from normalized coordinates to pixels

Returns:
the factor_n value (double)
Author:
Luis Alvarez & Luis Gomez
Parameters:
xx-Coordinates of points (pixels)
yy-Coordinates of points (pixels)
NlNumber of lines
NpNumber of points/line
x0x center of the image (pixels)
y0y center of the image (pixels)

Definition at line 2093 of file lens_distortion.cpp.

Here is the caller graph for this function:

int calculate_points ( double *  amin,
double **  points_2D_modified,
int  N,
int  Na,
double  x0,
double  y0 
)

function to estimate the position of 2D points (pixels) for the actual lens distortion model

   GRADIENT PART
Author:
Luis Alvarez and Luis Gomez
Returns:
return 0 if the function finishes properly
Parameters:
aminLens distortion model polynom
points_2D_modifiedCloud of points to be fitted to a line
NNumber of points
NaDegree of the lens distortion model
x0x center of the image
y0y center of the image

Definition at line 1246 of file lens_distortion.cpp.

Here is the caller graph for this function:

double cuadratic_fitting ( double *  amin_copy,
double *  amin,
double **  x,
double **  y,
int  Nl,
int *  Np,
int  Na,
double  lambda1,
double  lambda2,
double  lambda3,
double  f_1,
double  f_2,
double  f_3,
double *  grad_f,
int *  change_k 
)
Parameters:
amin_copyCopy of amin
aminLens distortion model polynom
xCoordinates of points
yCoordinates of points
NlNumber of lines
NpNumber of points/line
NaDegree of the lens distortion model polynomial
lambda1First TTP point
lambda2Second TTP point
lambda3Third TTP point
f_1f_objective(lambda1)
f_2f_objective(lambda2)
f_3f_objective(lambda3)
grad_fGradient vector at amin
change_kto indicate what variable optimize (1: optimize, 0: no optimize)

Definition at line 1447 of file lens_distortion.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

double distance_function ( double *  solution,
double **  x,
double **  y,
int  Nl,
int *  Np,
int  Na 
)
Parameters:
solution[Lens distortion model polynom;x0,y0]
xCoordinates of points
yCoordinates of points
NlNumber of lines
NpNumber of points/line
NaDegree of the lens distortion model

Definition at line 1278 of file lens_distortion.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

double find_lambda ( double  lambda1,
double  lambda2,
double  lambda3,
double  f_1,
double  f_2,
double  f_3,
double *  amin_copy,
double *  amin,
double **  x,
double **  y,
int  Nl,
int *  Np,
int  Na,
double *  grad_f,
int *  change_k 
)
Parameters:
lambda1First TTP point
lambda2Second TTP point
lambda3Third TTP point
f_1f_objective(lambda1)
f_2f_objective(lambda2)
f_3f_objective(lambda3)
amin_copyCopy of amin
aminLens distortion model polynom
xCoordinates of points
yCoordinates of points
NlNumber of lines
NpNumber of points/line
NaDegree of the lens distortion model polynomial
grad_fGradient vector at amin
change_kTo indicate what variable optimize (1: optimize, 0: no optimize)

Definition at line 1338 of file lens_distortion.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

double gradient_method ( double *  solution,
double **  x,
double **  y,
int  Nl,
int *  Np,
int  Na,
int *  change_k,
int  zoom,
int  optimize_center 
)

ZOOM UPDATE amin[0]

Parameters:
solution[Lens distortion model polynom;x0,y0]
xCoordinates of points
yCoordinates of points
NlNumber of lines
NpNumber of points/line
NaDegree of the lens distortion model polynomial
change_kto indicate what variable optimize (1: optimize, 0: no optimize)
zoomZoom strategy
optimize_centerTo optimize the center of distortion

Definition at line 1601 of file lens_distortion.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

double minimize_cuadratic_polynom ( double  lambda1,
double  lambda2,
double  lambda3,
double  f_1,
double  f_2,
double  f_3,
double *  amin_copy,
double *  amin,
double **  x,
double **  y,
int  Nl,
int *  Np,
int  Na,
double *  grad_f,
int *  change_k 
)
Parameters:
lambda1First TTP point
lambda2Second TTP point
lambda3Third TTP point
f_1f_objective(lambda1)
f_2f_objective(lambda2)
f_3f_objective(lambda3)
amin_copyCopy of amin
aminLens distortion model polynom
xCoordinates of points
yCoordinates of points
NlNumber of lines
NpNumber of points/line
NaDegree of the lens distortion model polynomial
grad_fGradient vector at amin
change_kTo indicate what variable optimize (1: optimize, 0: no optimize)

Definition at line 1396 of file lens_distortion.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

double minimize_lambda ( double *  amin,
double **  x,
double **  y,
int  Nl,
int *  Np,
int  Na,
double *  grad_f,
double  f,
int *  change_k 
)
Parameters:
amin[Lens distortion model polynom;x0,y0]
xCoordinates of points
yCoordinates of points
NlNumber of lines
NpNumber of points/line
NaDegree of the lens distortion model polynomial
grad_fGradient vector at amin
ffunction value at amin
change_kTo indicate what variable optimize (1: optimize, 0: no optimize)

Definition at line 1520 of file lens_distortion.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int optimize ( double *  solution,
double **  x,
double **  y,
double **  xx,
double **  yy,
int  Nl,
int *  Np,
int  Na,
double  factor_n,
int  zoom,
FILE *  fp1,
int  optimize_center 
)
Parameters:
solution[Lens distortion model polynom; x0,y0]
xCoordinates of points (normalized)
yCoordinates of points (normalized)
xxCoordinates of points
yyCoordinates of points
NlNumber of lines
NpNumber of points/line
NaDegree of the lens distortion model polynomial
factor_nFactor to normalize coordinates
zoomZoom strategy
fp1Pointer to the output file
optimize_centerTo optimize the center of distortion

Definition at line 1660 of file lens_distortion.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int read_line_primitives ( char  filename[300],
int *  Nl,
int **  Np,
double ***  x,
double ***  y 
)

function to read point line primitives

Author:
Luis Alvarez
Parameters:
filenameINPUT FILE NAME
NlOUTPUT NUMBER OF LINES
NpOUTPUT NUMBER OF POINTS FOR EACH LINE
xOUTPUT POINT X COORDINATES
yOUTPUT POINT X COORDINATES

Definition at line 2044 of file lens_distortion.cpp.

Here is the caller graph for this function:

int search_for_best_center ( int  Nl,
int *  Np,
double *  a,
double **  xx,
double **  yy,
int  width,
int  height,
double  max_radius 
)
Parameters:
NlNumber of lines
NpNumber of points/line
aLens distortion model polynom
xxCoordinates of points (pixels)
yyCoordinates of points (pixels)
widthImage size: width (pixels)
heightImage size: height (pixels)
max_radiusMAXIMUM RADIAL DISTANCE IN PHOTO

Definition at line 1934 of file lens_distortion.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int test_compatibility_lens_distortion_model ( double *  a,
int  Na,
double  max_radius 
)

function checks if the lens distortion model is an increasing function in [0,max_radius]

TOLERANCE FOR THE LAMBDA SEARCHING

Author:
Luis Alvarez
Returns:
return 0 if the test is satisfied

Definition at line 52 of file lens_distortion.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int trivial_solution ( int  Nl,
int *  Np,
double *  a,
double **  xx,
double **  yy,
double  factor_n,
FILE *  fp1,
double *  trivial,
int  optimize_center 
)
Parameters:
NlNumber of lines
NpNumber of points/line
aLens distortion model polynom
xxCoordinates of points
yyCoordinates of points
factor_nFactor to normalize coordinates
fp1Pointer to the output file
trivialTrivial Emin,Vmin,Dmin values
optimize_centerTo optimize the center of distortion

Definition at line 1852 of file lens_distortion.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

ami::image<unsigned char> undistort_image_inverse_fast ( ami::image< unsigned char >  input_image,
int  Na,
double *  a,
ami::point2d< double >  dc,
const double &  image_amplification_factor 
)

Definition at line 2299 of file lens_distortion.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

int f_evaluations = 0

TOTAL NUMBER OF ITERATIONS

Definition at line 42 of file lens_distortion.cpp.

int n_iterations = 0
This is the lens_distortion.cpp program (ANSI C language), associated to the
lens_distortion_estimation.cpp program; and to the publication
An Algebraic Approach to Lens Distortion by Line Rectification,
L. Alvarez, L. Gomez, R. Sendra
Published in JMIV, July 2009
Coded by Luis Alvarez and Luis Gomez, AMI Research Group, University of
Las Palmas de Gran Canaria, Canary Islands, SPAIN
First version: February 2010, Second Version: January 2012 (this is the second version)
In this version, we optimize the center of distortion using a search patch pattern strategy
   ALGEBRAIC PART

GLOBAL VARIABLES

Definition at line 41 of file lens_distortion.cpp.

double tol_lambda = 1e-8

TOTAL FUNCTION EVALUATIONS

Definition at line 43 of file lens_distortion.cpp.