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 detail and color in an image using the multiscale retinex algorithm |
last modified: December 15, 2018
USAGE: retinex [-m colormodel] [-f fact] [-c contrast] [-b bright] [-s sat] [-r res1,res2,res3] infile outfile
-m .... colormodel ........ processing colorspace; HSL or RGB; default=HSL PURPOSE: To enhance detail and color in an image using the multiscale retinex algorithm.
DESCRIPTION: RETINEX converts the intensity values in the image to
reflectance values at three resolution scales. This is achieved by
computing the log of the ratio of the image to each of three gaussian
blurred version of the image; one slightly blurred, one moderately
blurred and one severely blurred. The three results are then averaged
together. As this process sometimes desaturates the image an optional
color boost is provided. The color boost process creates a new image
which is the product of the resulting image with the log of the ratio of
the original image to its grayscale version. The color boosted image is
then blended with the previous result. The basic processing operation
prior to the color boost can be performed in RGB colorspace in order to
process each channel separately or it can be performed only on the
lightness channel in HSL colorspace. The latter may be prefered as
it tends to maintain the color balance from the original image. The
implementation of this script adapts the retinex approach developed
by NASA/Truview. See the following references: ARGUMENTS: -m colormodel ... COLORMODEL can be either RGB or HSL. If RGB is selected, then each of the R, G and B channels will be processed independently (possibly causing a color shift). If HSL is selected, then only the Lightness channel will be processed and then recombined with the Hue and Saturation channels and converted back to RGB. This option may be preferred as it will better maintain the relative color balance from the original image. The default is HSL. -f fact ... FACT specifies the color boost blending percentage. Values for fact may be an integer between 0 and 100. A value of 0 indicates no color boost. A value of 100 indicates full color boost. The default=0 -c contrast ... CONTRAST specifies a gamma control for contrast. Values for contrast must be positive floats or integers. A value of 1 indicates no contrast change. Larger/smaller values indicate lower/higher contrast. -b bright ... BRIGHT specifies a gain in brightness. Values for bright must be non-negative integers. A value of 100 indicates no brightness change. Larger/smaller values indicate brighter/darker results. -s sat ... SAT specifies a gain in saturation. Values for sat must be non-negative integers. A value of 100 indicates no saturation change. Larger/smaller values indicate more/less saturation. -r res1,res2,res3 ... RES1,RES2,RES3 specifies the three resolution levels in the retinex processing. They correspond to the pixel equivalent values to the sigma in the Gaussian blurring. These resolution values do not seem to be very sensitive such that variations to do not seem to make much change in the result. The default values are 5,20,240. NOTE: This script will be slow due the use of -fx, unless hdri is enabled. 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. |
Some examples are taken from and compared to NASA's retinex technique.
Color Boost Variations For Partially Shadowed Image | |||
NASA Original Image |
Arguments: |
Arguments: |
Arguments: |
NASA Original Image |
Arguments: |
Arguments: |
Arguments: |
Comparisons Of Enhancements For Overall Dark Image | ||||
Original Image |
retinex |
retinex |
space |
omnistretch |
redist |
redist |
-gamma 3 |
-normalize |
-equalize |
Comparisons Of Enhancements For Partially Shadowed Image | ||||
NASA Original Image |
NASA retinex |
retinex |
retinex |
redist -m RGB 50,80,80 |
space |
omnistretch -acc 3 |
-gamma 2 |
bcimage 20,-15 |
-equalize |
Comparisons Of Enhancements For Partially Shadowed Image | |||
NASA Original Image |
NASA retinex |
retinex -m RGB -f 85 |
retinex -m HSL -f 15 |
space |
redist -m RGB 60,60,60 |
-gamma 2 |
-equalize |
Comparisons Of Enhancements For Partially Shadowed Image | |||
NASA Original Image |
NASA Retinex |
retinex |
retinex |
space -m 0.7 -b 2.3 |
redist -m RGB 50,80,80 |
-gamma 2 |
-equalize |
Comparisons Of Enhancements For Hazy Image | |||
NASA Original Image |
NASA Retinex |
retinex -m RGB -f 20 |
retinex |
space |
redist -m RGB 60,60,30 |
-normalize |
-equalize |
Comparisons Of Enhancements For Hazy Image | |||
NASA Original Image |
NASA Retinex |
retinex |
retinex |
space |
omnistretch -acc 3 |
-normalize |
-equalize |
Comparisons Of Enhancements For Hazy Image | |||
NASA Original Image |
NASA Retinex |
retinex |
retinex |
space |
-normalize |
bcimage 10,40 |
redist -m RGB 50,40,40 |
What the script does is as follows:
This is equivalent to the following IM commands for
|