Download: latest (1.8.0)

pymagery — python imagery


1.4.0 documentation / histogram_equalize plugin

Histogram equalization is one algorithm to attempt to maximize the contrast of an image by means of the histogram. The basis to histogram equalization is the consider the histogram a sample of a probability distribution function (pdf). The pdf is then used to calculate the cummulative distribution function (cdf). The cdf is then linearized across the image's bit depth (0 to 255).

For imagines whose histogram is concentrated around certain values the histogram equalization is effectively stretching those values to use more of the available values.

The plugin prototype is:

hist, cdf, norm_cdf = def histogram_equalize()

The returned value is the original histogram, the original cdf, and the normalized cdf. The normalized cdf is what provides the mapping from the original pixel value to the new pixel value. The histogram is the result of the histogram plugin.

The following example equalizes the histogram of an image:

import pymagery i = pymagery.image('foo.ppm') hist, cdf, norm_cdf = i.histogram_equalize()

Change Log