LabKit MATLAB Workbench

reference

API ReferenceImage API

labkit.image.localContrast

Enhance local value-channel contrast with a mean-filter mask.

Syntax

imageOut = labkit.image.localContrast(imageIn, amountPct, radiusPx)

Description

Converts imageIn to clamped RGB double and operates on the HSV value channel. A square local mean with width 2*radius+1 forms the low-frequency reference. The difference between the value channel and that mean is multiplied by 1.5*amountPct/100 and added back before clipping.

Hue and saturation are preserved by the adjustment. At image boundaries, the local mean uses only available pixels. This is a lightweight local contrast operation, not adaptive histogram equalization.

Inputs

imageIn
Numeric or logical grayscale, RGB, or multichannel image.
amountPct
Numeric scalar effect strength in percent. Negative values are treated as 0.
radiusPx
Numeric scalar neighborhood radius in pixels. The value is rounded and limited to at least 1.

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. amountPct and radiusPx must be numeric scalars; incompatible values raise the originating conversion or indexing error.

Example

imageIn = repmat(linspace(0.2, 0.8, 20), 10, 1);
imageOut = labkit.image.localContrast(imageIn, 40, 3);

Source

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