Package: discorpy
Discorpy(Dis)tortion (Cor)rection (Py)thon-packageCamera calibration and distortion correction software for lens-based detector systemsDiscorpyis an open-source Python package designed for camera calibration and distortion
correction with sub-pixel accuracy. It calculates parameters of correction models
using a grid pattern image. Primarily, the package implements methods published inOptics Expressand offers a comprehensive
pipeline for data processing. Starting from version 1.4, the package also includes
perspective distortion correction capabilities.Author and maintainer:Nghia Vo,NSLS-II, Brookhaven National Laboratory, US; Diamond Light Source, UK.FeaturesThepolynomial modelused by the package is versatile enough to calibrate images with varying levels of
radial distortion. This practical feature eliminates the need for users to switch
between different models based on the degree of distortion in the images.Discorpy offers a unique feature whereradial distortion, the center of distortion, and perspective distortioncan be independently determined and corrected using a single calibration image.The software provides a full pipeline of data processing including:Pre-processing methodsfor: extracting reference-points from a dot-pattern image, line-pattern image,
and chessboard (checkerboard) image; grouping these points line-by-line.Processing methodsfor calculating
the optical center, coefficients of polynomial models for correcting radial distortion, and parameters
of a model for correcting perspective distortion.Post-processing methodsfor:
unwarping lines of points, images, or slices of a 3D dataset; and evaluating the accuracy of the correction results.Some methods may be useful for other applications:Correct non-uniform backgroundof an image.Selectbinary objectsin a certain range of values.Unwarp slices of a3D dataset.Installationhttps://discorpy.readthedocs.io/en/latest/install.htmlDocumentationhttps://discorpy.readthedocs.io/en/latest/UsageTo achieve high-accuracy results, the quality of the calibration image is crucial.
An ideal calibration image should containnumerous reference pointsextracted fromdot-patterns, line-patterns,
orcheckerboard images, covering most of
the camera's field of view and minimizing perspective distortion.https://discorpy.readthedocs.io/en/latest/usage.htmlDemonstrationsDetailed step-by-step demonstrations featuring codes and explanations of how to use Discorpy for various types of calibration images
are shownhere.Apply to a visible dot-target collected atBeamline I12,
Diamond Light Source, UK:Apply to an X-ray dot-target collected atBeamline I13,
Diamond Light Source, UK:Improvement of tomographic reconstructed images after distortion correction:For a detector with strong radial distortion:For a detector with small radial distortion:Calibrate a commercial camera with capabilities of correctingradial distortion and perspective distortionindependently.Calibrate a laptopwebcamusing a checkboard image.Apply to a hazard camera of theMars Perseverance Rover.
Details of how to estimate distortion coefficients of that camera without using
a calibration target are shownhere.Correctperspective distortion: