algebraic lens distortion
 All Classes Namespaces Files Functions Variables Defines
Functions
lens_distortion_estimation.cpp File Reference
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include "image.h"
#include "lens_distortion.h"
#include "point2d.h"
Include dependency graph for lens_distortion_estimation.cpp:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])

Function Documentation

int main ( int  argc,
char *  argv[] 
)

This is the main program (ANSI C language), associated to the publication An Algebraic Approach to Lens Distortion by Line Rectification, L. Alvarez, L. Gomez, R. Sendra Published in JMIV, July 2009 This program has the following components.

  • lens_distortion_estimation.cpp: (with the main() function)
  • lens_distortion.h:(having the prototypes of the functions being in lens_distortion.c)
  • lens_distortion.cpp:(Set of user defined brief functions for the algebraic and gradient methods)
  • ami_pol.h , ami.pol.cpp:(polynomial real root estimation library.)
  • image, libs:(Folder with basic libraries to read/write BMP, JPG, TIFF and PNG image formats. These libraries run both on 32-bit and 64-bit operating systems)
  • point2d.h: class to manage 2D points. 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 simple local search pattern strategy SUMMARY:
  • this program calculates the radial distortion parameters for the radial lens distortion model for a given image (input).
  • It is necessary to provide the primitives for a reference line which is known to be in the image (or some other straigth motif reference). This is not automatically done, it must be provided by the user.
  • It applies a new algebraic method (the one explained in the publication).
  • A standard numerical algorithm (gradient-like) is also implemented to minimize the distance function and to compare results with.
  • The center of distortion can be indicated by the user (to apply the center of the loaded image or a desired value) through the program input arguments.
  • The user can indicate if the center of distortion is considered fixed or it is going to be optimized, through the program input arguments. The center of distortion is optimized using a search patch pattern strategy operating at pixel precision. There is a patch (defined by default of size 20 x 20, in the lens_distortion.h header file #define patch_size 20). It is assumed that the user provides a valid estimate of the center of distortion, and, the simple pattern strategy, will locate it through the local search optimization strategy. Once it has been located, its value is optimized at subpixel level by means of the gradient. In order to optimize the center of distortion, user must provide more than one line, to avoid the center being too free (unconstrained optimization), and producing a bad solution. Note that increasing the patch size, increases the CPU time. Requeriments:

to be compiled using GCC (on Windows or Linux/UNIX systems).

INPUT/OUTPUT:

  • INPUT: an image in format BMP, JPG, TIFF or PNG which a radial distortion to be corrected.
  • OUTPUT:
    • the corrected distortion free image,
    • numerical results (optimized energy values, distortion parameters),
    • CPU time (just for the running not for the pre-and post- processing phases). IMPORTANT: CPU time strongly depends on the size image, not being linearly scaled for the gradient method. IMPORTANT: This is the code for the improved version of the original first IPOL published algorithm (February 2010) New version of the code (January 2012)

Definition at line 107 of file lens_distortion_estimation.cpp.

Here is the call graph for this function: