OpenCV 5.0.0-pre
Open Source Computer Vision
Loading...
Searching...
No Matches
Chromatic Aberration Correction

Detailed Description

Functions

void cv::correctChromaticAberration (InputArray input_image, InputArray coefficients, OutputArray output_image, const Size &image_size, int calib_degree, int bayer_pattern=-1)
 Corrects lateral chromatic aberration in an image using polynomial distortion model.
 
void cv::loadChromaticAberrationParams (const FileNode &node, OutputArray coeffMat, Size &calib_size, int &degree)
 Load chromatic-aberration calibration parameters from opened FileStorage.
 

Function Documentation

◆ correctChromaticAberration()

void cv::correctChromaticAberration ( InputArray input_image,
InputArray coefficients,
OutputArray output_image,
const Size & image_size,
int calib_degree,
int bayer_pattern = -1 )
Python:
cv.correctChromaticAberration(input_image, coefficients, image_size, calib_degree[, output_image[, bayer_pattern]]) -> output_image

#include <opencv2/photo.hpp>

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 [236]. 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.

Parameters
input_imageInput BGR image to correct
coefficientsCoefficient model
output_imageCorrected 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_image has one channel; ignored otherwise.
See also
loadChromaticAberrationParams, demosaicing

◆ loadChromaticAberrationParams()

void cv::loadChromaticAberrationParams ( const FileNode & node,
OutputArray coeffMat,
Size & calib_size,
int & degree )
Python:
cv.loadChromaticAberrationParams(node[, coeffMat]) -> coeffMat, calib_size, degree

#include <opencv2/photo.hpp>

Load chromatic-aberration calibration parameters from opened FileStorage.

R e*ads the red and blue polynomial coefficients from the specified file and packs them into a 4×N CV_32F matrix: row 0 = blue dx coefficients row 1 = blue dy coefficients row 2 = red dx coefficients row 3 = red dy coefficients

Parameters
nodeNode of opened cv::FileStorage object.
coeffMatOutput 4xN coefficient matrix (CV_32F).
degreePolynomial degree inferred from N.
calib_sizeCalibration image size read from file.
See also
correctChromaticAberration
Examples
samples/cpp/snippets/chromatic_aberration_correction.cpp.