Fred's ImageMagick Scripts
|
Computes the normalized entropy of an image channel-by-channel |
last modified: May 17, 2011
|
USAGE: entropy infile -h or -help .... Displays help information PURPOSE: To compute the normalized entropy of an image channel-by-channel. DESCRIPTION: ENTROPY computes the normalized entropy of an image channel-by-channel. Entropy is a measure of graylevel distribution (disorder or randomness) in the histogram. It is not a measure of spatial disorder or spatial randomness in the image. The entropy is computed from the histogram of the channel by accumulating -p*ln(p) over every 8-bit graylevel, where p = (count for a given graylevel) / (total pixels). The normalized entropy is equal to the entropy/ln(256). For example, if the image is a single grayscale, then the entropy=0. If the image is a uniform gradient including all values from 0 to 255 that are equally populated in the histogram, then the entropy=1. When the colorspace is Gray, only one Gray entropy value will be printed. When the colorspace is CMYK, the following 5 values will be printed: Cyan, Magenta, Yellow and Black Entropies and the Average of those four entropies. When the colorspace is RGB or any other colorspace, then the following 4 values will be printed to the terminal: Red, Green and Blue Entropies and the Average of those three entropies. For any colorspace other than RGB, then Red, Green and Blue should then be interpreted as channels 1, 2 and 3, respectively, for that colorspace. CAVEAT: No guarantee that this script will work on all platforms, nor that trapping of inconsistent parameters is complete and foolproof. Use At Your Own Risk. |
|
Image And Spectrum | |
|
Original Image |
Entropy |
|
Gray Entropy = 0.125 |
|
Gray Entropy = 0.873 |
|
Red Entropy = 0.523204 |
|
Red Entropy = 0.905032 |
|
Red Entropy = 0.92939 |
|
What the script does is as follows:
This is equivalent to the following IM commands for a graylevel image:
|