correctChromaticAberration
import { correctChromaticAberration } from '@banou/opencv-wasm'Use after await initOpenCV(). See the initialization and named imports guide.
photo_render
example: samples/cpp/snippets/chromatic_aberration_correction.cpp An example correcting chromatic aberration with C++ example: samples/python/snippets/chromatic_aberration_correction.py An example correcting chromatic aberration with Python Corrects lateral chromatic aberration in an image using polynomial distortion model.
This function loads polynomial calibration data from the specified file and applies
a channel‐specific warp to remove chromatic aberration.
If input_image has one channel, it is assumed to be a raw Bayer image and is
first demosaiced using bayer_pattern. If it has three channels, it is treated
as a BGR image and bayer_pattern is ignored.
Firstly, calibration needs to be done using apps/chromatic-aberration-calibration/ca_calibration.py on a photo of a pattern of black discs on white background, included in opencv_extra/testdata/cv/cameracalibration/chromatic_aberration/chromatic_aberration_pattern_a3.png
Calibration and correction are based on the algorithm described in [rudakova2013precise]. The chromatic aberration is modeled as a polynomial of some degree in red and blue channels compared to green. In calibration, a photo of many black discs on white background is used, and the displacements between the centres of discs in red and blue channels compared to green are minimized. The coefficients are then saved in a yaml file which can be used with this function to correct lateral chromatic aberration.
See: loadChromaticAberrationParams, demosaicing
correctChromaticAberration(input_image: Mat, coefficients: Mat, output_image: Mat, image_size: Size, calib_degree: number, bayer_pattern: number): void;2 available overloads
correctChromaticAberration(input_image: Mat, coefficients: Mat, output_image: Mat, image_size: Size, calib_degree: number): void;correctChromaticAberration(input_image: Mat, coefficients: Mat, output_image: Mat, image_size: Size, calib_degree: number, bayer_pattern: number): void;input_imageInput BGR image to correct
coefficientsCoefficient model
output_imageOutput destination, filled by the native operation. Corrected BGR image
image_sizeSize of images for the calibration coefficient model
calib_degreeDegree of the calibration coefficient model
bayer_patternBayer pattern code (e.g. cv::COLOR_BayerBG2BGR) used for demosaicing when
input_imagehas one channel; ignored otherwise.
These signatures describe this package. Upstream documentation can mention optional backends that are absent from this build. Check runtime compatibility before choosing a backend or file format.