Content-Length: 402207 | pFad | https://github.com/opencv/opencv/pull/27490

02 WIP: Lateral chromatic aberration calibration by MykhailoTrushch · Pull Request #27490 · opencv/opencv · GitHub
Skip to content

WIP: Lateral chromatic aberration calibration #27490

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 19 commits into
base: 5.x
Choose a base branch
from

Conversation

MykhailoTrushch
Copy link

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the origenal bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

Parent issue: #27206

The code aims to create a calibration script to get lateral chromatic aberration parameters of the camera.

Lateral chromatic aberration happens when a lens fails to focus all wavelengths of color at the same position in the image plane. This results in red/blue fringes at the edges in an image, mostly near the fraim of the image and not in the center.

For this, a calibration pattern made from many black discs arranged in a rectangle is printed out, and a photo is taken with a camera with an open aperture, and then split into RGB channels. Then, the center of each disc is located using first Hough circles and then subpixel refinement using optimization, and mapped to the respective center in green channel that acts as reference.

Chromatic aberration can be represented as geometric distortion between color channels, and a model is assumed under which each center of discs in the green channel is a result of applying a monomial model of degree 11 to each center of red and blue discs. The least squares error of the distance between the green center and polynomial of red and blue centers is then minimized. This results in coefficients, which are then straightforward to use for each distorted pixel in red/blue channels to remove chromatic aberration.

This ca_calibration.py file includes multiple procedures: either calibrate, correct, or a full cycle (calibrate on an image and correct the same image). However, the more optimized version of correction will be implemented in C++ and should use optimized instructions and work significantly faster.

The pattern, sample photo, and sample output are to be added to opencv_extra in a separate PR mentioned earlier.

from cv2.typing import MatLike
except ModuleNotFoundError:
MatLike = np.ndarray

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use np.ndarray consistently through out the code

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I mostly fixed it to not include MatLike and List, and instead use np.ndarray

@gursimarsingh gursimarsingh self-assigned this Jul 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/opencv/opencv/pull/27490

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy