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:
The following example generates the histogram of an image:
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:
- ['r'] — the histogram of red subpixels (0 to 255)
- ['g'] — the histogram of green subpixels (0 to 255)
- ['b'] — the histogram of blue subpixels (0 to 255)
- ['v'] — the histogram of r+g+b values (0 to 765)
Change Log
- 1.0.0 — added