Download: latest (1.8.0)

pymagery — python imagery


1.1.0 documentation / histogram plugin

The histogram is a 1-dimensional characterization of the image, while not unique it does provide some insight into the image. The histogram is a simply tally of the pixel values present within the image. This is straight-forward for monochrome and grayscale images but not so with RGB images. For RGB images, the histogram generated is a separate histogram of each color channel.

The plugin prototype is:

bins = def histogram()

The following example generates the histogram of an image:

import pymagery i = pymagery.image('foo.ppm') hist = i.histogram()

Exactly what is in hist depends on the mode of the image. If the image is monochrome or grayscale then the returned value is a dictionary indexed on pixel value and values are counts for that pixel value. If the image is RGB then the return is a dictionary containing four histograms:

The last histogram is not normalized to 0 to 255 for the sake of not losing data.

Change Log