Correction for radial distortion and perspective distortion in Python
Project description
Discorpy
(Dis)tortion (Cor)rection (Py)thon-package
Camera calibration and distortion correction software for lens-based detector systems
Discorpy is 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 in Optics Express and 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.
Features
- The polynomial model used 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 where radial distortion, the center of distortion, and perspective distortion can be independently determined and corrected using a single calibration image.
- The software provides a full pipeline of data processing including:
- Pre-processing methods for: extracting reference-points from a dot-pattern image, line-pattern image, and chessboard (checkerboard) image; grouping these points line-by-line.
- Processing methods for calculating the optical center, coefficients of polynomial models for correcting radial distortion, and parameters of a model for correcting perspective distortion.
- Post-processing methods for: 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 background of an image.
- Select binary objects in a certain range of values.
- Unwarp slices of a 3D dataset.
Installation
Documentation
Usage
- To achieve high-accuracy results, the quality of the calibration image is crucial. An ideal calibration image should contain numerous reference points extracted from dot-patterns, line-patterns, or checkerboard images, covering most of the camera's field of view and minimizing perspective distortion.
- https://discorpy.readthedocs.io/en/latest/usage.html
Demonstrations
-
Detailed step-by-step demonstrations featuring codes and explanations of how to use Discorpy for various types of calibration images are shown here.
-
Apply to a visible dot-target collected at Beamline I12, Diamond Light Source, UK:
-
Apply to an X-ray dot-target collected at Beamline 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 correcting radial distortion and perspective distortion independently.
-
Calibrate a laptop webcam using a checkboard image.
-
Apply to a hazard camera of the Mars Perseverance Rover. Details of how to estimate distortion coefficients of that camera without using a calibration target are shown here.
-
Correct perspective distortion:
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file discorpy-1.6.0.tar.gz
.
File metadata
- Download URL: discorpy-1.6.0.tar.gz
- Upload date:
- Size: 46.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ee2b8e7f04efbdc214fd7954bc5aa36cd3b69cc9412473b8b66a5003f46a8e6 |
|
MD5 | b7c8ca26b0db9611388cd72bad033c76 |
|
BLAKE2b-256 | d4e7f985b837efd1b9b728c1180a39ac12d539b3568746b2a590d00f9d741d5f |
File details
Details for the file discorpy-1.6.0-py3-none-any.whl
.
File metadata
- Download URL: discorpy-1.6.0-py3-none-any.whl
- Upload date:
- Size: 39.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9532b2f32c10e98821bc7a009997291a01f32dc2576ac9b1c3c19be7d019a12b |
|
MD5 | b5fa68f381479078e4ffc3f27ea454a1 |
|
BLAKE2b-256 | 88487ab58829a4fc9b6509c8380cb2a30f149b7ae84796368baaa8eea7c78317 |