reference
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);Related APIs
labkit.image.adjustBrightnessContrast— Apply simple brightness and contrast adjustment.labkit.image.adjustHueSaturation— Apply HSV hue and saturation adjustment.labkit.image.assertSupportedPaths— Throw when any path has an unsupported image extension.labkit.image.displayName— Return a short image-file display name.labkit.image.ensureRgb— Return image data with exactly three color channels.labkit.image.fileDialogFilter— Return a file-chooser-compatible image filter.labkit.image.im2double— Convert image data to double using MATLAB's im2double contract.labkit.image.isSupportedPath— Return true when a path has a supported image extension.
Source
This page is generated from the MATLAB help text in +labkit/+image/grayWorldWhiteBalance.m.