HISTEQ

Purpose:

Performs histogram equalization of an image.

Syntax:

HISTEQ(image, spec)

image

-

An array, the input image.

spec

-

Optional. An integer or series. If omitted or an integer, performs standard histogram equalization to a uniform distribution with the specified number of bins. Default = 64. If a series, matches the histogram shape of the provided reference distribution (histogram matching).

Returns:

An image.

Example:

W1: readimage(gethome + "\data\siblings.tif", "Gray8");scalesoff

W2: histeq(w1);setaspect(-1);scalesoff

W3: imcombine(w1, w2);scalesoff;label("Histogram Equalization")

 

W1 loads a TIFF image as an 8-bit grayscale image with intensity values between 0 and 255.

W2 applies histogram equalization, remapping the original intensity distribution toward a more uniform spread for better contrast.

W3 displays the original and equalized images side-by-side for visual comparison.

 

 

Histogram Equalization

Example:

W1: Readimage(gethome + "\Data\kasha.jpg", "Gray8");scalesoff;label("Orignal")

W2: histeq(W1);setaspect(-1);scalesoff;label("Uniform")

W3: histeq(W1, pdfnorm(1..255, 128, 32));setaspect(-1);scalesoff;label("Gaussian")

W4: imhist(W1)

W5: imhist(W2)

W6: imhist(W3)

 

Histogram Matching

W1 loads a color JPEG image and converts it to 8-bit grayscale with intensity values 0 to 255.

W2 performs standard histogram equalization, spreading intensities toward a uniform distribution for improved overall contrast

W3 performs histogram matching, remapping the image so its intensity distribution approximates the specified Gaussian (normal) distribution.

W4–W6 display the histograms of the original, uniformly equalized, and Gaussian-matched images respectively, allowing visual verification of the transformation.

Remarks:

HISTEQ enhances image contrast by remapping pixel intensities based on the image's cumulative distribution function (CDF).

 

If spec is omitted, HISTEQ uses a uniform (flat) distribution with 64 output intensity levels. If spec is an integer, a uniform distribution with the specified number of output levels is used. If spec is a series, its values define the desired histogram shape directly. The series is automatically normalized so that its total count matches the number of pixels in image.

 

The mapping is built by ranking each source gray level against the cumulative distribution of the target. The output level for a given source level is the count of target cumulative bins it has already exceeded, so the result is bin for bin nondecreasing by construction. See [1] for details on the underlying histogram specification technique.

 

HISTEQ expects a grayscale image, with values in the range 0 to 255. However, if the input is a 24 bit RGB image, it is converted to HSV space, the V channel is equalized and the result is converted back to an RGB image.

 

See IMHIST to compute the intensity histogram of an image.

See Also:

AMPDIST

HISTOGRAM

IMAGE24

IMCOMBINE

IMHIST

PARTSUM

References:

[1]

Gonzalez & Woods

 

Digital Image Processing

 

Pearson Prentice Hall, 2008

 

Sec. 3.3