Copyright © Fred Weinhaus My scripts are available free of charge for non-commercial (non-profit) use, ONLY. For use of my scripts in commercial (for-profit) environments or non-free applications, please contact me (Fred Weinhaus) for licensing arrangements. My email address is fmw at alink dot net. If you: 1) redistribute, 2) incorporate any of these scripts into other free applications or 3) reprogram them in another scripting language, then you must contact me for permission, especially if the result might be used in a commercial or for-profit environment. Usage, whether stated or not in the script, is restricted to the above licensing arrangements. It is also subject, in a subordinate manner, to the ImageMagick license, which can be found at: http://www.imagemagick.org/script/license.php Please read the Pointers For Use on my home page to properly install and customize my scripts. |
Computes the normalized entropy of an image channel-by-channel |
last modified: April 23, 2021
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:
|