Main Content

localcontrast

Edge-aware local contrast manipulation of images

Description

example

B = localcontrast(A) enhances the local contrast of the grayscale or RGB image A.

B = localcontrast(A,edgeThreshold,amount) enhances or flattens the local contrast of A by increasing or smoothing details while leaving strong edges unchanged. edgeThreshold defines the minimum intensity amplitude of strong edges to leave intact. amount is the amount of enhancement or smoothing desired.

Examples

collapse all

Import an RGB image.

A = imread('peppers.png');

Increase the local contrast of the input image.

edgeThreshold = 0.4;
amount = 0.5;
B = localcontrast(A, edgeThreshold, amount);

Display the results compared to the original image

imshowpair(A, B, 'montage')

Reduce the local contrast of the input image.

amount = -0.5;
B2 = localcontrast(A, edgeThreshold, amount);

Display the new results again, compared to the original image.

imshowpair(A, B2, 'montage')

Input Arguments

collapse all

Grayscale or RGB image to be filtered, specified as a real, non-sparse, m-by-n or m-by-n-by-3 matrix.

Data Types: single | int8 | int16 | uint8 | uint16

Amplitude of strong edges to leave intact, specified as a numeric scalar in the range [0,1].

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Amount of enhancement or smoothing desired, specified as a numeric scalar in the range [-1,1]. Negative values specify edge-aware smoothing. Positive values specify edge-aware enhancement.

ValueDescription
0Leave input image unchanged.
1Strongly enhance the local contrast of the input image
-1Strongly smooth the details of the input image

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Output Arguments

collapse all

Filtered image, returned as a numeric array the same size and class as the input image.

Version History

Introduced in R2016b