algebraic lens distortion

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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:

  Nl | Number of lines
  Np | Number of points/line
  a | Lens distortion model polynom
  x | Coordinates of points (normalized)
  y | Coordinates of points (normalized)
  xx | Coordinates of points
  yy | Coordinates of points
  factor_n | Factor to normalize coordinates
  zoom | Zoom strategy
  fp1 | Pointer to the output file
  optimize_center | To optimize the center of distortion
  max_radius | MAXIMUM 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:

  p1 | POLYNOM 1 (INPUT)
  N1 | DEGREE OF POLYNOM 1 (INPUT)
  p2 | POLYNOM 2 (INPUT)
  N2 | DEGREE OF POLYNOM 2 (INPUT)
  p3 | OUTPUT 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:

  p | ORIGINAL POLYNOM (INPUT)
  N | DEGREE OF THE ORIGINAL POLYNOM (INPUT)
  p_x | DERIVATIVE OF THE POLYNOM WITH RESPECT TO THE FIRST VARIABLE (OUTPUT)
  p_y | DERIVATIVE 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:

  p1 | 2 VARIABLE POLYNOM (INPUT)
  N1 | DEGREE OF POLYNOM 1 (INPUT)
  y | POINT 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:

  p1 | POLYNOM 1 (INPUT)
  N1 | DEGREE OF POLYNOM 1 (INPUT)
  p2 | POLYNOM 2 (INPUT)
  N2 | DEGREE OF POLYNOM 2 (INPUT)
  p3 | OUTPUT 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:

  p1 | 2 VARIABLE POLYNOM (INPUT)
  N1 | DEGREE OF POLYNOM 1 (INPUT)
  p3 | OUTPUT 1 VARIABLE POLYNOM (OUTPUT)
  z | POINT 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,y | POINT TO INVERSE (INPUT)
  [in] | x0,y0 | LENS DISTORTION MODEL CENTER (INPUT)
  [out] | *xt,*yt | UNDISTORTED POINT (INVERSE POINT TRANSFORMED) (OUTPUT)
  [in] | *a | LENS DISTORTION MODEL COEFFICIENTS
  [in] | Na | DEGREE 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:

  y | ORIGINAL COLECCION OF LINES DISTRIBUTION (INPUT)
  Nl | NUMBER OF LINES
  Np | NUMBER OF POINTS FOR EACH LINE(INPUT)
  y0 | CENTER OF THE IMAGE (INPUT)
  a | Lens Distortion Polynomial model (INPUT-OUTPUT)
  Na | Degree of Polynomial model (INPUT)
  k | COEFFICIENT OF THE LENS DISTORTION POLYNOM MODEL TO BE UPDATED
  alpha | WEIGHT FOR MINIMIZING THE SQUARE OF THE DISTANCE BETWEEN DISTORTED AND UNDISTORTED POINTS
  max_radius | MAX 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:

  y | DISTORTED LINE COORDINATES (INPUT)
  Nl | NUMBER OF LINES (RECTS)
  Np | NUMBER OF POINTS (INPUT)
  y0 | COORDINATES OF THE IMAGE CENTER
  a | POLYNOMIAL DEFINING THE LENS DISTORTION MODEL (INPUT)
  Na | DEGREE OF POLYNOMIAL MODEL FOR LENS DISTORTION
  k1 | COEFFICIENT 1 OF THE POLYNOMIAL TO BE UPDATED
  k2 | COEFFICIENT 2 OF THE POLYNOMIAL TO BE UPDATED
  alpha | WEIGHT OF THE DISTANCE IN THE POLYNOM ENERGY
  max_radius | MAXIMUM 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] | a | INPUT POLYNOMIAL DISTORTION MODEL
  [in] | Na | INPUT DEGREE OF POLYNOMIAL DISTORTION MODEL
  [in] | xc,yc | INPUT CENTER OF DISTORTION
  [in] | x_input,y_input | INPUT POINT
  [out] | x_output,y_output | OUTPUT 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:

  a | POLYNOMIAL DEFINING THE LENS DISTORTION MODEL (INPUT-OUTPUT)
  Na | DEGREE OF POLYNOMIAL MODEL FOR LENS DISTORTION (INPUT)
  k | COEFFICIENT OF THE POLYNOMIAL TO BE UPDATED (INPUT)
  pol | 4 DEGREE POLYNOM TO MINIMIZE (INPUT)
  max_radius | MAX 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:

  a | POLYNOMIAL DEFINING THE LENS DISTORTION MODEL (INPUT-OUTPUT)
  Na | DEGREE OF POLYNOMIAL MODEL FOR LENS DISTORTION (INPUT)
  k1 | COEFFICIENT 1 OF THE POLYNOMIAL TO BE UPDATED (INPUT)
  k2 | COEFFICIENT 2 OF THE POLYNOMIAL TO BE UPDATED (INPUT)
  pol | 4 DEGREE POLYNOM TO MINIMIZE (INPUT)
  max_radius | MAXIMUM 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:

  y | DISTORTED LINE COORDINATES (INPUT)
  Np | NUMBER OF POINTS (INPUT)
  a | POLYNOMIAL DEFINING THE LENS DISTORTION MODEL (INPUT)
  Na | DEGREE OF POLYNOMIAL MODEL FOR LENS DISTORTION
  y0 | COORDINATES OF THE IMAGE CENTER
  k | COEFFICIENT OF THE POLYNOMIAL TO BE UPDATED
  pol | 4 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:

  y | DISTORTED LINE COORDINATES (INPUT)
  Np | NUMBER OF POINTS (INPUT)
  a | POLYNOMIAL DEFINING THE LENS DISTORTION MODEL (INPUT)
  Na | DEGREE OF POLYNOMIAL MODEL FOR LENS DISTORTION
  y0 | COORDINATES OF THE IMAGE CENTER
  k1 | COEFFICIENT 1 OF THE POLYNOMIAL TO BE UPDATED
  k2 | COEFFICIENT 2 OF THE POLYNOMIAL TO BE UPDATED
  pol | 4 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:

  y | DISTORTED LINE COORDINATES (INPUT)
  Np | NUMBER OF POINTS (INPUT)
  a | POLYNOMIAL DEFINING THE LENS DISTORTION MODEL (INPUT)
  Na | DEGREE OF POLYNOMIAL MODEL FOR LENS DISTORTION
  y0 | COORDINATES OF THE IMAGE CENTER
  k1 | COEFFICIENT 1 OF THE POLYNOMIAL TO BE UPDATED
  k2 | COEFFICIENT 2 OF THE POLYNOMIAL TO BE UPDATED
  pol | 4 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:

  | y | ORIGINAL COLECCION OF LINES DISTRIBUTION (INPUT)
  | Nl | NUMBER OF LINES
  | Np | NUMBER OF POINTS FOR EACH LINE(INPUT)
  [in,out] | a |
  | Na | Degree 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:

  y | ORIGINAL POINT DISTRIBUTION (INPUT)
  Np | NUMBER OF POINTS (INPUT)
  y0 | CENTER OF THE IMAGE (INPUT)
  a | Lens Distortion Polynomial model (INPUT)
  Na | Degree 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:

  y | ORIGINAL POINT DISTRIBUTION (INPUT)
  Np | NUMBER OF POINTS (INPUT)
  y0 | CENTER OF THE IMAGE (INPUT)
  a | Lens Distortion Polynomial model (INPUT)
  Na | Degree 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:

  line | line coefficients (ax+by+c=0)
  Points2D | set of 2D points
  N | number 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:

  a | POLYNOM COEFFICIENT
  Na | POLYNOM DEGREE
  x | POINT 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:

  a | POLYNOMIAL COEFFICIENTS a[0]+a[1]x+a[2]x^2 +...
  N | DEGREE OF POLYNOMIAL (IT HAS TO BE 3)
  x | POLYNOMIAL 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:

  x | x-Coordinates of points (pixels)
  y | y-Coordinates of points (pixels)
  Nl | Number of lines
  Np | Number of points/line
  x0 | x center of the image (pixels)
  y0 | y 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:

  amin | Lens distortion model polynom
  points_2D_modified | Cloud of points to be fitted to a line
  N | Number of points
  Na | Degree of the lens distortion model
  x0 | x center of the image
  y0 | y 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_copy | Copy of amin
  amin | Lens distortion model polynom
  x | Coordinates of points
  y | Coordinates of points
  Nl | Number of lines
  Np | Number of points/line
  Na | Degree of the lens distortion model polynomial
  lambda1 | First TTP point
  lambda2 | Second TTP point
  lambda3 | Third TTP point
  f_1 | f_objective(lambda1)
  f_2 | f_objective(lambda2)
  f_3 | f_objective(lambda3)
  grad_f | Gradient vector at amin
  change_k | to 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]
  x | Coordinates of points
  y | Coordinates of points
  Nl | Number of lines
  Np | Number of points/line
  Na | Degree 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:

  lambda1 | First TTP point
  lambda2 | Second TTP point
  lambda3 | Third TTP point
  f_1 | f_objective(lambda1)
  f_2 | f_objective(lambda2)
  f_3 | f_objective(lambda3)
  amin_copy | Copy of amin
  amin | Lens distortion model polynom
  x | Coordinates of points
  y | Coordinates of points
  Nl | Number of lines
  Np | Number of points/line
  Na | Degree of the lens distortion model polynomial
  grad_f | Gradient vector at amin
  change_k | To 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]
  x | Coordinates of points
  y | Coordinates of points
  Nl | Number of lines
  Np | Number of points/line
  Na | Degree of the lens distortion model polynomial
  change_k | to indicate what variable optimize (1: optimize, 0: no optimize)
  zoom | Zoom strategy
  optimize_center | To 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:

  lambda1 | First TTP point
  lambda2 | Second TTP point
  lambda3 | Third TTP point
  f_1 | f_objective(lambda1)
  f_2 | f_objective(lambda2)
  f_3 | f_objective(lambda3)
  amin_copy | Copy of amin
  amin | Lens distortion model polynom
  x | Coordinates of points
  y | Coordinates of points
  Nl | Number of lines
  Np | Number of points/line
  Na | Degree of the lens distortion model polynomial
  grad_f | Gradient vector at amin
  change_k | To 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]
  x | Coordinates of points
  y | Coordinates of points
  Nl | Number of lines
  Np | Number of points/line
  Na | Degree of the lens distortion model polynomial
  grad_f | Gradient vector at amin
  f | function value at amin
  change_k | To 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]
  x | Coordinates of points (normalized)
  y | Coordinates of points (normalized)
  xx | Coordinates of points
  yy | Coordinates of points
  Nl | Number of lines
  Np | Number of points/line
  Na | Degree of the lens distortion model polynomial
  factor_n | Factor to normalize coordinates
  zoom | Zoom strategy
  fp1 | Pointer to the output file
  optimize_center | To 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:

  filename | INPUT FILE NAME
  Nl | OUTPUT NUMBER OF LINES
  Np | OUTPUT NUMBER OF POINTS FOR EACH LINE
  x | OUTPUT POINT X COORDINATES
  y | OUTPUT 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:

  Nl | Number of lines
  Np | Number of points/line
  a | Lens distortion model polynom
  xx | Coordinates of points (pixels)
  yy | Coordinates of points (pixels)
  width | Image size: width (pixels)
  height | Image size: height (pixels)
  max_radius | MAXIMUM 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:

  Nl | Number of lines
  Np | Number of points/line
  a | Lens distortion model polynom
  xx | Coordinates of points
  yy | Coordinates of points
  factor_n | Factor to normalize coordinates
  fp1 | Pointer to the output file
  trivial | Trivial Emin,Vmin,Dmin values
  optimize_center | To 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.