#include <stdio.h>#include <stdlib.h>#include <math.h>#include <malloc.h>#include <string.h>#include <time.h>#include <vector>#include "ami_pol.h"#include "point2d.h"#include "image.h"

Go to the source code of this file.
Defines | |
| #define | PI 3.1415927 |
| #define | ABS(x) (((x)>0)?(x):-(x)) |
| #define | Normalize(x) ((x)<0?0:((x)>255?255:x)) |
| #define | Max(a, b) ((a>b)?a:b) |
| #define | ami_abs(x) ((x)>0?(x):(-(x))) |
| #define | ami_calloc2d(address, datatype, height, width) |
| #define | ami_malloc2d(address, datatype, height, width) |
| #define | ami_malloc2d_pointers(address, simple_pointer, datatype, height, width) |
| #define | ami_free2d(address) { free(address[0]); free(address); } |
| #define | ami_free2d_pointers(address) { free(address); } |
| #define | ami_malloc1d(address, datatype, size) {address=(datatype *) malloc(sizeof(datatype)*(size));} |
| #define | ami_calloc1d(address, datatype, size) |
| #define | ami_max_iter 1000 |
| #define | ami_tol 0.0000001 |
| #define | line_length 80 /* LENGTH OF LINE (TO READ A LINE FOR A FILE) */ |
| #define | max_itera 100 /* MAXIMUM NUMBER OF GRADIENT ITERATIONS */ |
| #define | delta 1.0e-10 /* DERIVATIVE STEP (FINITE DIFFERENCES) */ |
| #define | max_itera_lambda 10 /* MAXIMUM NUMBER OF ITERATIONS IN UNIDIMENSIONAL SEARCH */ |
| #define | tol_f 1.0e-6 /* TOLERANCE TO STOP THE GRADIENT ITERATIONS */ |
| #define | tol_norma 1.0e-16 /* NORM OF GRADIENT TO STOP THE GRADIENT ALGORITHM */ |
| #define | patch_size 20 |
| #define | max_itera_patch 20 /* MAXIMUM NUMBER OF SEARCH-OF-DISTORTION-CENTER ITERATIONS */ |
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) |
| function to update the lens distortion model by minimizing a 4 degree polynom | |
| 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) |
| function to compute the lens distortion model | |
| void | ami_lens_distortion_zoom_normalization (double **x, double **y, int Nl, int *Np, double *solution, 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) |
| 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 | |
| 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 | read_line_primitives (char filename[300], int *Nl, int **Np, double ***x, double ***y) |
| function to read point line primitives | |
| int | search_for_best_center (int N, int *Np, double *a, double **xx, double **yy, int width, int height, double max_radius) |
| 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 | ami_inverse_lens_distortion_fast (double x, double y, double x0, double y0, double *xt, double *yt, double *a, int Na, double dl1r) |
| 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) |
| #define ABS | ( | x | ) | (((x)>0)?(x):-(x)) |
Definition at line 29 of file lens_distortion.h.
| #define ami_abs | ( | x | ) | ((x)>0?(x):(-(x))) |
Definition at line 32 of file lens_distortion.h.
| #define ami_calloc1d | ( | address, | |
| datatype, | |||
| size | |||
| ) |
{int ml; address=(datatype *) malloc(sizeof(datatype)*(size)); \
for(ml=0;ml<size;ml++) address[ml]=0;\
}
Definition at line 52 of file lens_distortion.h.
| #define ami_calloc2d | ( | address, | |
| datatype, | |||
| height, | |||
| width | |||
| ) |
{int ml,mk; \
address=(datatype **) malloc(sizeof(datatype *)*(height)); \
address[0]=(datatype *)malloc(sizeof(datatype)*(width)*(height)); \
for(ml=0;ml<(height);ml++) address[ml]=&(address[0][ml*(width)]); \
for(ml=0;ml<height;ml++) for(mk=0;mk<width;mk++) address[ml][mk]=0; \
}
Definition at line 33 of file lens_distortion.h.
| #define ami_free2d | ( | address | ) | { free(address[0]); free(address); } |
Definition at line 49 of file lens_distortion.h.
| #define ami_free2d_pointers | ( | address | ) | { free(address); } |
Definition at line 50 of file lens_distortion.h.
| #define ami_malloc1d | ( | address, | |
| datatype, | |||
| size | |||
| ) | {address=(datatype *) malloc(sizeof(datatype)*(size));} |
Definition at line 51 of file lens_distortion.h.
| #define ami_malloc2d | ( | address, | |
| datatype, | |||
| height, | |||
| width | |||
| ) |
{int ml; \
address=(datatype **) malloc(sizeof(datatype *)*(height)); \
address[0]=(datatype *)malloc(sizeof(datatype)*(width)*(height)); \
for(ml=0;ml<(height);ml++) address[ml]=&(address[0][ml*(width)]);\
}
Definition at line 39 of file lens_distortion.h.
| #define ami_malloc2d_pointers | ( | address, | |
| simple_pointer, | |||
| datatype, | |||
| height, | |||
| width | |||
| ) |
{int ml; \
address=(datatype **) malloc(sizeof(datatype *)*(height)); \
address[0]=(datatype *) simple_pointer; \
for(ml=0;ml<(height);ml++) address[ml]=&(address[0][ml*(width)]);\
}
Definition at line 44 of file lens_distortion.h.
| #define ami_max_iter 1000 |
BEGIN: ALGEBRAIC CONTROL PARAMETERS
Definition at line 60 of file lens_distortion.h.
| #define ami_tol 0.0000001 |
Definition at line 61 of file lens_distortion.h.
| #define delta 1.0e-10 /* DERIVATIVE STEP (FINITE DIFFERENCES) */ |
Definition at line 75 of file lens_distortion.h.
| #define line_length 80 /* LENGTH OF LINE (TO READ A LINE FOR A FILE) */ |
END: ALGEBRAIC CONTROL PARAMETERS
Definition at line 68 of file lens_distortion.h.
| #define Max | ( | a, | |
| b | |||
| ) | ((a>b)?a:b) |
Definition at line 31 of file lens_distortion.h.
| #define max_itera 100 /* MAXIMUM NUMBER OF GRADIENT ITERATIONS */ |
BEGIN: GRADIENT CONTROL PARAMETERS
Definition at line 74 of file lens_distortion.h.
| #define max_itera_lambda 10 /* MAXIMUM NUMBER OF ITERATIONS IN UNIDIMENSIONAL SEARCH */ |
Definition at line 76 of file lens_distortion.h.
| #define max_itera_patch 20 /* MAXIMUM NUMBER OF SEARCH-OF-DISTORTION-CENTER ITERATIONS */ |
Definition at line 88 of file lens_distortion.h.
| #define Normalize | ( | x | ) | ((x)<0?0:((x)>255?255:x)) |
Definition at line 30 of file lens_distortion.h.
| #define patch_size 20 |
END: GRADIENT CONTROL PARAMETERS BEGIN: SEARCH-OF-DISTORTION-CENTER PARAMETERS
Definition at line 87 of file lens_distortion.h.
| #define PI 3.1415927 |
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
Definition at line 28 of file lens_distortion.h.
| #define tol_f 1.0e-6 /* TOLERANCE TO STOP THE GRADIENT ITERATIONS */ |
Definition at line 77 of file lens_distortion.h.
| #define tol_norma 1.0e-16 /* NORM OF GRADIENT TO STOP THE GRADIENT ALGORITHM */ |
Definition at line 78 of file lens_distortion.h.
| 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 | ||
| ) |
| 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.


| 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
| 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.

| 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
| 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.

| double ami_2v_polynom_evaluation | ( | double ** | p1, |
| int | N1, | ||
| double | x, | ||
| double | y | ||
| ) |
function to evaluate a 2 variable polynom in one point
| 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.


| void ami_2v_polynom_multiplication | ( | double ** | p1, |
| int | N1, | ||
| double ** | p2, | ||
| int | N2, | ||
| double ** | p3 | ||
| ) |
function to multiply polynoms of 2 variables
| 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.

| 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
| 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.


| 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 | ||
| ) |
COMPUTE THE INVERSE OF LENS DISTORTION MODEL IN A POINT USING NEWTON-RAPHSON.
| [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 |
Definition at line 2182 of file lens_distortion.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 | alpha | ||
| ) |
function 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 | ||
| ) |
| 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.


| 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 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 |
Definition at line 2156 of file lens_distortion.cpp.

| int ami_lens_distortion_model_update | ( | double * | a, |
| int | Na, | ||
| int | k, | ||
| double * | pol | ||
| ) |
function to update the lens distortion model by minimizing a 4 degree polynom
| int ami_lens_distortion_model_update_2v | ( | double * | a, |
| int | Na, | ||
| int | k1, | ||
| int | k2, | ||
| double ** | pol, | ||
| double | max_radius | ||
| ) |
| 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.


| 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
| 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.


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


| 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
| 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.


| void ami_lens_distortion_zoom_normalization | ( | double ** | x, |
| double ** | y, | ||
| int | Nl, | ||
| int * | Np, | ||
| double * | solution, | ||
| int | Na | ||
| ) |
| y | ORIGINAL COLECCION OF LINES DISTRIBUTION (INPUT) | |
| Nl | NUMBER OF LINES | |
| Np | NUMBER OF POINTS FOR EACH LINE(INPUT) | |
| [in,out] | solution | |
| Na | Degree of Polynomial model (INPUT) |
Definition at line 1205 of file lens_distortion.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 (the residual variance of the point distribution
| 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.


| 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
| 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.


| 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
| 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.

| void ami_polynom_determinant | ( | double | p[6][6][19], |
| int | Np, | ||
| int | Nd, | ||
| double * | q | ||
| ) |
function to compute the determinant of a polynom matrix
Definition at line 630 of file lens_distortion.cpp.


| double ami_polynomial_evaluation | ( | double * | a, |
| int | Na, | ||
| double | x | ||
| ) |
function to evaluate a polynom using the Horner algorithm
| a | POLYNOM COEFFICIENT |
| Na | POLYNOM DEGREE |
| x | POINT WHERE THE POLYNOM IS EVALUATED |
Definition at line 860 of file lens_distortion.cpp.

| 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
| 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.

| 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.


| 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
| xx | x-Coordinates of points (pixels) |
| yy | 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.

| 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
| 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.

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


| double distance_function | ( | double * | solution, |
| double ** | x, | ||
| double ** | y, | ||
| int | Nl, | ||
| int * | Np, | ||
| int | Na | ||
| ) |
| 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.


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


| 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]
| 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.


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


| double minimize_lambda | ( | double * | amin, |
| double ** | x, | ||
| double ** | y, | ||
| int | Nl, | ||
| int * | Np, | ||
| int | Na, | ||
| double * | grad_f, | ||
| double | f, | ||
| int * | change_k | ||
| ) |
| 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.


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


| int read_line_primitives | ( | char | filename[300], |
| int * | Nl, | ||
| int ** | Np, | ||
| double *** | x, | ||
| double *** | y | ||
| ) |
function to read point line primitives
| 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.

| int search_for_best_center | ( | int | N, |
| int * | Np, | ||
| double * | a, | ||
| double ** | xx, | ||
| double ** | yy, | ||
| int | width, | ||
| int | height, | ||
| double | max_radius | ||
| ) |
| N | 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.


| 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]
END: SEARCH-OF-DISTORTION-CENTER PARAMETERS
TOLERANCE FOR THE LAMBDA SEARCHING
Definition at line 52 of file lens_distortion.cpp.


| int trivial_solution | ( | int | Nl, |
| int * | Np, | ||
| double * | a, | ||
| double ** | xx, | ||
| double ** | yy, | ||
| double | factor_n, | ||
| FILE * | fp1, | ||
| double * | trivial, | ||
| int | optimize_center | ||
| ) |
| 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.


| 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.


1.8.0