ccm_ColorCorrectionModel
import { ccm_ColorCorrectionModel } from '@banou/opencv-wasm'Use after await initOpenCV(). See the initialization and named imports guide.
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;srcdetected colors of ColorChecker patches; the color type is RGB not BGR, and the color values are in [0, 1];
constColorthe Built-in color card
colorsthe reference color values, the color values are in [0, 1].
refColorSpacethe corresponding color space If the color type is some RGB, the format is RGB not BGR;
coloredPatchesMaskbinary mask indicating which patches are colored (non-gray) patches
The ccm_ColorCorrectionModel result.
Upstream declaration ↗Upstream declaration 2 ↗Upstream declaration 3 ↗
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;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;csthe absolute color space that detected colors convert to; default:
COLOR_SPACE_SRGB
setCcmType
ccm_ColorCorrectionModel.setCcmType: set ccmType
setCcmType(ccmType: number): void;ccmTypethe shape of color correction matrix(CCM); default:
CCM_LINEAR
setDistance
ccm_ColorCorrectionModel.setDistance: set Distance
setDistance(distance: number): void;distancethe type of color distance; default:
DISTANCE_CIE2000
setLinearization
ccm_ColorCorrectionModel.setLinearization: set Linear
setLinearization(linearizationType: number): void;linearizationTypethe method of linearization; default:
LINEARIZATION_GAMMA
setLinearizationGamma
set Gamma
Note: only valid when linear is set to "gamma";
setLinearizationGamma(gamma: number): void;gammathe 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;degthe 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;lowerthe lower threshold to determine saturation; default: 0;
upperthe upper threshold to determine saturation; default: 0
setWeightsList
set WeightsList
setWeightsList(weightsList: Mat): void;weightsListthe list of weight of each color; default: empty array
setWeightCoeff
set WeightCoeff
setWeightCoeff(weightsCoeff: number): void;weightsCoeffthe exponent number of L* component of the reference color in CIE Lab color space; default: 0
setInitialMethod
set InitialMethod
setInitialMethod(initialMethodType: number): void;initialMethodTypethe method of calculating CCM initial value; default: INITIAL_METHOD_LEAST_SQUARE
setMaxCount
ccm_ColorCorrectionModel.setMaxCount: set MaxCount
setMaxCount(maxCount: number): void;maxCountused in MinProblemSolver-DownhillSolver; Terminal criteria to the algorithm; default: 5000;
setEpsilon
ccm_ColorCorrectionModel.setEpsilon: set Epsilon
setEpsilon(epsilon: number): void;epsilonused 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;rgbIf 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;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;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;The number result.
getSrcLinearRGB
Return the src linear rgb configured on this ccm_ColorCorrectionModel object.
getSrcLinearRGB(): Mat;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;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;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;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;srcInput 8-bit, 16-bit unsigned or 32-bit float 3-channel image..
dstOutput destination, filled by the native operation. Output image of the same size and datatype as src.
islineardefault false.
write
ccm_ColorCorrectionModel.write native operation from cv::ccm::ColorCorrectionModel::write.
write(fs: FileStorage): void;fsfs argument (FileStorage).
read
ccm_ColorCorrectionModel.read native operation from cv::ccm::ColorCorrectionModel::read.
read(node: FileNode): void;nodenode 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.