LabKit MATLAB Workbench

reference

API ReferenceImage API

labkit.image.grayWorldWhiteBalance

Apply generic gray-world white balance.

Syntax

imageOut = labkit.image.grayWorldWhiteBalance(imageIn, strengthPct, temperaturePct)

Description

Estimates one gain per RGB channel so that the three channel means move toward their common mean. strengthPct blends between the original image and the fully balanced result. This is the gray-world assumption: over a representative scene, the average reflected color is expected to be neutral.

temperaturePct adds a small red offset and subtracts the same blue offset after gain correction. Positive values produce a warmer result; negative values produce a cooler result. The temperature offset is 0.08 times the normalized percentage. Final values are clamped to [0,1].

Inputs

imageIn
Numeric or logical grayscale, RGB, or multichannel image.
strengthPct
Numeric scalar blend percentage. Values below 0 become 0; values above 100 become 100.
temperaturePct
Numeric scalar warm/cool adjustment in percent. Use 0 for neutral gray-world balancing.

Outputs

imageOut
M-by-N-by-3 double image with values in [0,1].

Failure Behavior

Unsupported image classes or channel shapes propagate errors from im2double or ensureRgb. strengthPct and temperaturePct must participate in scalar numeric arithmetic; incompatible MATLAB values raise the originating conversion or array-size error.

Example

imageIn = cat(3, 0.3*ones(4), 0.5*ones(4), 0.7*ones(4));
imageOut = labkit.image.grayWorldWhiteBalance(imageIn, 100, 0);

Source

This page is generated from the MATLAB help text in +labkit/+image/grayWorldWhiteBalance.m.