FUNCTION REFERENCE

histeq

Enhance contrast by histogram equalisation.

Enhance contrast by histogram equalisation.

Syntax

J = histeq(I)

Syntax

J = histeq(I, n)

Syntax

J = histeq(I, hgram)

Syntax

[J, T] = histeq(I, ...)

Maps the intensities of a 2-D image so that its histogram over n output levels (default 64) is about flat, or about proportional to the target counts hgram. The 256-bin histogram of I (as imhist bins it) gives cumulative counts c0; the target, scaled to the pixel count, gives cumulative counts c1. Bin k goes to the level j whose c1(j) is closest to c0(k) without falling short of it by more than half the count of bin k (ties take the darker level), so T is monotonic. Output level j of n is (j - 1)/(n - 1) of the class range; J has the class of I (logical input gives double) and T is the 1-by-256 map as fractions in [0, 1].

Example

J = histeq(uint8([0 10 20 30; 40 50 60 70]))   % uint8([28 61 93 125; 158 190 223 255])

Example

[J, T] = histeq(uint8(repmat(0:99, 100, 1)), 4); imhist(J, 4)'   % [2500 2500 2500 2500]

Example

J = histeq([0.1 0.2 0.3 0.9; 0.5 0.5 0.6 0.7], 4)   % [0 1/3 0 1; 1/3 1/3 2/3 1]

Differences from MATLAB: no colormap form (histeq(X, map)), no gpuArray; the mapping is the documented rule, so individual pixels may land one level apart from MATLAB.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.