Fred's ImageMagick Scripts



    Licensing:

    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.

ENHANCELAB


Applies brightness/contrast/colorization enhancement on an image via LAB colorspace.

Download Script

last modified: December 15, 2018



USAGE: enhancelab [-b blackpt ] [-w whitept] [-g gammaval] [-s sigmoid] [-c colorize] infile outfile
USAGE: enhancelab [-h or -help]

-b ... blackpt .... black point percent value for level adjustment of the L
................... channel; 0<=integer<=100; default=0 (no change)
-w ... whitept .... white point percent value for level adjustment of the L
................... channel; 0<=integer<=100; default=100 (no change)
-g ... gammaval ... gamma value for non-linear adjustment on the L channel;
................... float>0; default=1 (no change)
-s ... sigmoid .... sigmoidal contrast value for non-linear adjustment of
................... the L channel; float (positive or negative); default=0
................... (no change)
-c ... colorize .... percent change in colorization; integer (positive or
................... negative; default=0 (no change)

PURPOSE: To apply brightness/contrast/colorization enhancement on an image via LAB colorspace.

DESCRIPTION: ENHANCELAB applies brightness/contrast/colorization enhancement on an image via LAB colorspace.

ARGUMENTS:

-b blackpt ... BLACKPT is the black point percent value for level adjustment of the L channel. Values are integers between 0 and 100. The default=0 (no change)

-w whitept ... WHITEPT is the white point percent value for level adjustment of the L channel. Values are integers between 0 and 100. The default=0 (no change)

-g gammaval ... GAMMAVAL is the gamma value for non-linear adjustment on the L channel. Values are floats greater than 0. The default=1 (no change)

-s sigmoid ... SIGMOID is the sigmoidal contrast value for non-linear adjustment of the L channel. Values are floats (positive or negative). The default=0 (no change)

-c colorize ... COLORIZE is the percent change in colorization. Values are integers (positive or negative). The default=0 (no change)

REQUIREMENTS: IM 6.7.8.2 or higher, when the LAB colorspace conversions were fixed.

REFERENCE: http://digital-photography-school.com/turn-ho-hum-color-into-wow-with-photoshop

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.


EXAMPLES


Original Image

 

Arguments:
-g 1.3 -c 30


Original Image

 

Arguments:
-w 90 -c 30


Original Image

 

Arguments:
-w 80 -g 1.3 -c 30


What the script does is as follows:

  • Converts the image to LAB colorspace
  • Applies a combination of -level and -sigmoidal-contrast to L channel
  • Applies -level with equal adjustments to the white and black points
    and equally to the A and B channels
  • Converts the changes back to sRGB colorspace

This is equivalent to the following IM commands.

  • low=$colorize
  • high=$((100-$colorize))
  • test=`convert xc: -format "%[fx:$sigmoid<0?1:0]" info:`
  • if [ $test -eq 1 ]; then
    sign=+
    else
    sign=-
    fi
  • [ "$sigmoid" = "0" ] && sigmoid=0.001
  • convert $tmpA1 -colorspace LAB \
    -channel R -level ${blackpt}%,${whitept}%,$gammaval \
    ${sign}sigmoidal-contrast ${sigmoid},50% +channel \
    -channel GB -level ${low}%,${high}% +channel \
    -colorspace sRGB \
    $outfile