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. |
Enhances the contrast/brightness in an image using an adaptive gamma method. |
last modified: November 17, 2023
USAGE: adaptivegamma2 [-t type][-m meanthresh] [-f fraction] [-c cumthresh]
[-bg brightgain] [-dg darkgain] [-ba brightalpha] [-da darkalpha] [-C colormode]
infile outfile
-t .... type ............ type of mean threshold to use; choices are: orginial or simple; PURPOSE: To enhance the contrast/brightness in an image using an adaptive gamma method. DESCRIPTION: ADAPTIVEGAMMA2 is an adaptive gamma technique used to enhance an image's brightness and contrast. It is based upon an exponentiation of the the image's values using an exponent, gamma, that is evaluated differently for each graylevel in the image based upon values in the cumulative normalized and weight histogram in the form, gamma(value)=1-cumulative_histogram(value). The fraction along with the meanthresh value are used to categorize the image as bright, dark (or neutral if type=original). Neutral images will have no processing applied. For dark images the cumulative distribution is clipped not to exceed cumthresh. For bright images, no clipping is used, but the input is negated before gamma processing and then negated back after processing. ARGUMENTS: -t type ... TYPE of mean threshold to use. The choices are: orginial or simple. The default=simple. -m meanthresh ... MEANTHRESH is a threshold of the mean that is used to test if the image is bright or dark. Values are 0<=integer<=255. The default=128. (Use 112 for original). -f fraction ... FRACTION to use with the meanthresh to test if the image is bright or dark. Values are 0<=float<=1. The default=0.3. -c cumthresh ... CUMTHRESH is a threshold used to clip the cumulative distribution for dark images. Values are 0<=float<=1. The default=0.55. -bg brightgain ... BRIGHTGAIN ia a gain on cumulative distribution for bright images. Values are 0<=float<=1. The default=1 (no change). -dg darkgain ... DARKGAIN is a gain on cumulative distribution for dark images. Values are 0<=float<=1. The default=1 (no change). -ba brightalpha ... BRIGHTALPHA is an alpha exponent for weighting the normalize histogram for bright images. Values are 0<=float<=1. The default=0.25. -da darkalpha ... DARKALPHA is an alpha exponent for weighting the normalize histogram for dark images. Values are 0<=float<=1. The default=0.75. -C colormode ... COLORMODE is the colorspace for processing; choices are srgb, lab, hcl, hsl, hsv, hsi, ycbcr and ohta; default=hsv
REFERENCES: NOTE: This script may be a bit slow due for non-HDRI compile Imagemagick to the use of -fx. 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. |
Example 1 -- Variation in ColorMode |
||
Original Image |
||
Arguments: -C hsv (default) |
Arguments: -C hsl |
Arguments: -C hsi |
Arguments: -C hcl |
Arguments: -C srgb |
Arguments: -C lab |
Arguments: -C YCbCr |
Arguments: -C OHTA |
Arguments:   |
Original Image |
|
Arguments: (defaults) |
Original Image |
|
Arguments: (defaults) |
Original Image |
|
Arguments: (defaults) |
Original Image |
|
Arguments: (defaults) |
Original Image |
|
Arguments: (defaults) |
Original Image |
|
Arguments: (defaults) |
Original Image |
|
Arguments: (defaults) |
Original Image |
|
Arguments: (defaults) |
Original Image |
|
Arguments: (defaults) |
Original Image |
|
Arguments: (defaults) |
Original Image |
|||
|
|||
Arguments: -gt 0.55 -dg 1 (defaults) |
Arguments: -gt 0.55 -dg 0.7 |
Arguments: -gt 0 -dg 1 |
Arguments: -gt 0 --dg 0.7 |
Original Image |
|
|
|
Arguments: -gt 0.55 -dg 1 (defaults) |
Arguments: -gt 0.55 -bg 0.8 |
What the script does is as follows:
|