Skip to main content

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

GitHub Workflow Status Downloads former_vounwarp_downloads Anaconda-Server Badge Documentation Status Anaconda-Server Badge GitHub code size in bytes Anaconda-Server Badge Coverage

Discorpy is an open-source Python package implementing methods for calibrating and correcting distortion in lens-based imaging systems (1, 2). Unlike existing approaches that require multiple calibration images or iterative optimization, Discorpy and its algorithms can independently characterize both radial and perspective distortion with high accuracy across a wide range of distortion strengths - using only a single calibration image and direct computation. This makes the software a practical tool for a wide range of imaging applications.

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:

Installation

Documentation

Usage

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:

    I12_before_after1

    I12_before_after2

  • Apply to an X-ray dot-target collected at Beamline I13, Diamond Light Source, UK:

    I13_before_after1

    I13_before_after2

  • Improvement of tomographic reconstructed images after distortion correction:

    • For a detector with strong radial distortion:

      tomo_strong

    • For a detector with small radial distortion:

      tomo_small

  • Calibrate a commercial camera with capabilities of correcting radial distortion and perspective distortion independently.

    show_case

  • Calibrate a laptop webcam using a checkboard image.

    webcam_before

    webcam_after

  • Calibrate a fisheye camera (GoPro Hero-8).

    GoPro_Hero8

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

    Percy_cam1

    Percy_cam2

  • Correct perspective distortion:

    perspective_correction

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

discorpy-1.7.0.tar.gz (57.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

discorpy-1.7.0-py3-none-any.whl (48.5 kB view details)

Uploaded Python 3

File details

Details for the file discorpy-1.7.0.tar.gz.

File metadata

  • Download URL: discorpy-1.7.0.tar.gz
  • Upload date:
  • Size: 57.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.13

File hashes

Hashes for discorpy-1.7.0.tar.gz
Algorithm Hash digest
SHA256 ff2016f9527bb844e95a64b2ff0b61c9346cdac20490fa63c69fa59c625e2360
MD5 6c4b6184435691f70d342def1f91859b
BLAKE2b-256 cf3f1b7d98c9128d541dff4b9bc03102393526d3fc597909be0ee95fc29e640a

See more details on using hashes here.

File details

Details for the file discorpy-1.7.0-py3-none-any.whl.

File metadata

  • Download URL: discorpy-1.7.0-py3-none-any.whl
  • Upload date:
  • Size: 48.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.13

File hashes

Hashes for discorpy-1.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 399a357ae39b5cc364690cc0b0bb6c793d3f47966ff3672060383fca8d114847
MD5 69bdfb835908766079879742d00f33ce
BLAKE2b-256 cadec04138a95d55c1f656ff48827c31f64daf491851f6763024cd0d28f76c2d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page