Skip to content

ccm_ColorCorrectionModel

Computational photographyclassOpenCV 5.0.0
import { ccm_ColorCorrectionModel } from '@banou/opencv-wasm'

Use after await initOpenCV(). See the initialization and named imports guide.

ARGUMENTSConstructor or factory
CLASSccm_ColorCorrectionModel
RETURN TYPEOwned native handle
Call structure. A void return can still write to destination arguments. The parameter descriptions define inputs, outputs and ownership.

Native object: release it with using or delete(). Factories can return null; check before calling methods.

Core class of ccm model

Produce a ColorCorrectionModel instance for inference

Constructors and members

static new

Color Correction Model

    Supported list of color cards:
    - `COLORCHECKER_MACBETH`, the Macbeth ColorChecker
    - `COLORCHECKER_VINYL`, the DKK ColorChecker
    - `COLORCHECKER_DIGITAL_SG`, the DigitalSG ColorChecker with 140 squares
new(src: Mat, colors: Mat, refColorSpace: ccm_ColorSpace, coloredPatchesMask: Mat): ccm_ColorCorrectionModel;
4 available overloads
new(): ccm_ColorCorrectionModel;
new(src: Mat, constColor: number): ccm_ColorCorrectionModel;
new(src: Mat, colors: Mat, refColorSpace: ccm_ColorSpace): ccm_ColorCorrectionModel;
new(src: Mat, colors: Mat, refColorSpace: ccm_ColorSpace, coloredPatchesMask: Mat): ccm_ColorCorrectionModel;
src

detected colors of ColorChecker patches; the color type is RGB not BGR, and the color values are in [0, 1];

constColor

the Built-in color card

colors

the reference color values, the color values are in [0, 1].

refColorSpace

the corresponding color space If the color type is some RGB, the format is RGB not BGR;

coloredPatchesMask

binary mask indicating which patches are colored (non-gray) patches

Returns

The ccm_ColorCorrectionModel result.

clone

Create another handle to the same native object. This retains the object without copying its pixels or algorithm state; dispose both handles separately.

clone(): this;
Returns

The this result.

setColorSpace

set ColorSpace

Note: It should be some RGB color space; Supported list of color cards: - COLOR_SPACE_SRGB - COLOR_SPACE_ADOBE_RGB - COLOR_SPACE_WIDE_GAMUT_RGB - COLOR_SPACE_PRO_PHOTO_RGB - COLOR_SPACE_DCI_P3_RGB - COLOR_SPACE_APPLE_RGB - COLOR_SPACE_REC_709_RGB - COLOR_SPACE_REC_2020_RGB

setColorSpace(cs: number): void;
cs

the absolute color space that detected colors convert to; default: COLOR_SPACE_SRGB

setCcmType

ccm_ColorCorrectionModel.setCcmType: set ccmType

setCcmType(ccmType: number): void;
ccmType

the shape of color correction matrix(CCM); default: CCM_LINEAR

setDistance

ccm_ColorCorrectionModel.setDistance: set Distance

setDistance(distance: number): void;
distance

the type of color distance; default: DISTANCE_CIE2000

setLinearization

ccm_ColorCorrectionModel.setLinearization: set Linear

setLinearization(linearizationType: number): void;
linearizationType

the method of linearization; default: LINEARIZATION_GAMMA

setLinearizationGamma

set Gamma

Note: only valid when linear is set to "gamma";

setLinearizationGamma(gamma: number): void;
gamma

the gamma value of gamma correction; default: 2.2;

setLinearizationDegree

set degree

Note: only valid when linear is set to - LINEARIZATION_COLORPOLYFIT - LINEARIZATION_GRAYPOLYFIT - LINEARIZATION_COLORLOGPOLYFIT - LINEARIZATION_GRAYLOGPOLYFIT

setLinearizationDegree(deg: number): void;
deg

the degree of linearization polynomial default: 3

setSaturatedThreshold

set SaturatedThreshold. The colors in the closed interval [lower, upper] are reserved to participate in the calculation of the loss function and initialization parameters

setSaturatedThreshold(lower: number, upper: number): void;
lower

the lower threshold to determine saturation; default: 0;

upper

the upper threshold to determine saturation; default: 0

setWeightsList

set WeightsList

setWeightsList(weightsList: Mat): void;
weightsList

the list of weight of each color; default: empty array

setWeightCoeff

set WeightCoeff

setWeightCoeff(weightsCoeff: number): void;
weightsCoeff

the exponent number of L* component of the reference color in CIE Lab color space; default: 0

setInitialMethod

set InitialMethod

setInitialMethod(initialMethodType: number): void;
initialMethodType

the method of calculating CCM initial value; default: INITIAL_METHOD_LEAST_SQUARE

setMaxCount

ccm_ColorCorrectionModel.setMaxCount: set MaxCount

setMaxCount(maxCount: number): void;
maxCount

used in MinProblemSolver-DownhillSolver; Terminal criteria to the algorithm; default: 5000;

setEpsilon

ccm_ColorCorrectionModel.setEpsilon: set Epsilon

setEpsilon(epsilon: number): void;
epsilon

used in MinProblemSolver-DownhillSolver; Terminal criteria to the algorithm; default: 1e-4;

setRGB

Set whether the input image is in RGB color space

setRGB(rgb: boolean): void;
rgb

If true, the model expects input images in RGB format. If false, input is assumed to be in BGR (default).

compute

make color correction

compute(): Mat;
Returns

The Mat result. Release returned native handles with using or delete(), including handles nested in results.

getColorCorrectionMatrix

Return the color correction matrix configured on this ccm_ColorCorrectionModel object.

getColorCorrectionMatrix(): Mat;
Returns

The Mat result. Release returned native handles with using or delete(), including handles nested in results.

getLoss

Return the loss configured on this ccm_ColorCorrectionModel object.

getLoss(): number;
Returns

The number result.

getSrcLinearRGB

Return the src linear rgb configured on this ccm_ColorCorrectionModel object.

getSrcLinearRGB(): Mat;
Returns

The Mat result. Release returned native handles with using or delete(), including handles nested in results.

getRefLinearRGB

Return the ref linear rgb configured on this ccm_ColorCorrectionModel object.

getRefLinearRGB(): Mat;
Returns

The Mat result. Release returned native handles with using or delete(), including handles nested in results.

getMask

Return the mask configured on this ccm_ColorCorrectionModel object.

getMask(): Mat;
Returns

The Mat result. Release returned native handles with using or delete(), including handles nested in results.

getWeights

Return the weights configured on this ccm_ColorCorrectionModel object.

getWeights(): Mat;
Returns

The Mat result. Release returned native handles with using or delete(), including handles nested in results.

correctImage

Applies color correction to the input image using a fitted color correction matrix.

The conventional ranges for R, G, and B channel values are: - 0 to 255 for CV_8U images - 0 to 65535 for CV_16U images - 0 to 1 for CV_32F images

correctImage(src: Mat, dst: Mat, islinear: boolean): void;
2 available overloads
correctImage(src: Mat, dst: Mat): void;
correctImage(src: Mat, dst: Mat, islinear: boolean): void;
src

Input 8-bit, 16-bit unsigned or 32-bit float 3-channel image..

dst

Output destination, filled by the native operation. Output image of the same size and datatype as src.

islinear

default false.

write

ccm_ColorCorrectionModel.write native operation from cv::ccm::ColorCorrectionModel::write.

write(fs: FileStorage): void;
fs

fs argument (FileStorage).

read

ccm_ColorCorrectionModel.read native operation from cv::ccm::ColorCorrectionModel::read.

read(node: FileNode): void;
node

node argument (FileNode).

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.