Fred's ImageMagick Scripts



    Licensing:

    Copyright © Fred Weinhaus

    My scripts are available free of charge for non-commercial 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

CHROME


Applies a chrome effect to a binary image.

Download Script

last modified: September 26, 2017



USAGE: chrome [-i intensity] [-n numcycles] [-s smooth] [-a azimuth] [-e elevation] [-c color] [-b bgcolor] [-f fuzzfact] infile outfile
USAGE: chrome [-h or -help]

-i .... intensity ....... intensity of chrome effect; integer>=0;
......................... default=100 (nominal)
-n .... numcycles ....... number of cycles in the chrome lookup table;
......................... integer>0; default=2
-s .... smooth .......... smoothing amount; float>=0; default=3
-a .... azimuth ......... azimuth angle for light source; 0<=integer<=360;
......................... counterclockwise from positive x axis (East);
......................... default=135 (NorthWest)
-e .... elevation ....... elevation angle for light source; 0<=integer<=90;
......................... upwards from x-y plane; default=45;
-c .... color ........... color for chrome effect; any valid IM color;
......................... default=no special coloration
-b .... bgcolor ......... background color outside chrome area; any valid
......................... IM color including none for transparent
-d .... dilation ........ dilation of alpha channel; integer>=0; default=1
-B .... brightness ...... percent brightness change; -100<=integer<=100;
......................... default=0
-C .... contrast ........ percent contrast change; -100<=integer<=100;
......................... default=0
-A .... alpha ........... alpha channel handling; choices are: off or
......................... extract; if off, the alpha channel is turned off;
......................... if extract, the alpha channel is used in place of
......................... the image; default is no change of input alpha
......................... status.

PURPOSE: To apply a chrome effect to a binary image.

DESCRIPTION: CHROME applies an chrome effect to a binary image. Coloration is optional.

ARGUMENTS:

-i intensity ... INTENSITY of chrome effect. This brings out contrast. Values are integers>=0. The default=100 is the nominal values.

-n numcycles ... NUMCYCLES is the number of cycles in the chrome look up table that controls the type of chrome effect. Values are integers>0. The default=2.

-s smooth ... SMOOTH is the amount of smoothing to apply to chrome effect. Values are floats>=0. The default=3.

-a azimuth ... AZIMUTH is the angle in degrees in the x-y plane measured counterclockwise from EAST to the light source. Values are integers in the range 0<=azimuth<=360. The default=135 (NorthWest).

-e elevation ... ELEVATION is the angle in degrees upwards from the x-y plane to the light source. Values are integers in the range 0<=elevation<=90. The default=45.

-c color ... COLOR is the optional color to apply to the chrome effect. Any valid IM color is allowed. The default is no additional color on top of the natural chrome effect.

-b bgcolor ... BGCOLOR is the optional background color outside the chromed items. Any valid IM color is allowed including none for transparency. The default is no special background color.

-d dilation ... DILATION of alpha channel when bgcolor is specified. Values are integers>=0. The default=1.

-B brightness ... percent BRIGHTNESS change. Values are -100<=integer<=100. The default=0.

-C contrast ... percent CONTRAST change; Values are -100<=integer<=100. The default=0.

-A alpha ... ALPHA channel handling. The choices are: off (o) or extract (e). If off, then the alpha channel is turned off and the image is used alone. If extract, then the alpha channel is used in place of the base image. The default is no change of input image alpha status.

REQUIREMENTS: IM 6.4.8-9 in order to support -function sinusoid.

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


Variation In Intensity

Original
(http://www.codeproject.com/KB/GDI-plus/Image_Processing_Lab.aspx)

Arguments:
-i 50

Arguments:
-i 100

Arguments:
-i 200



Variation In Numcycles

Original

Arguments:
-n 1

Arguments:
-n 2

Arguments:
-n 3

Arguments:
-n 4

Arguments:
-n 5

Arguments:
-n 6



Variation In Smoothing

Original

Arguments:
-s 2

Arguments:
-s 3

Arguments:
-s 4



Variation In Coloring

Original

Arguments:
-c lightblue

Arguments:
-c lightblue -b none

Arguments:
-c lightblue -b red



Variation In Dilation

Original

Arguments:
-c lightblue -b none -d 0

Arguments:
-c lightblue -b none -d 1

Arguments:
-c lightblue -b none -d 2



What the script does is as follows:

  • Creates a special rising cyclical look up table
  • Applies a smoothing blur to the input image
  • Applies a shading to the blurred image
  • Applies the lut to the shaded blurred image

This is equivalent to the following IM commands

  • amp0=`convert xc: -format "%[fx:$amplitude/100]" info:`
  • amp1=`convert xc: -format "%[fx:$amp0/($amp0+1)]" info:`
  • amp2=`convert xc: -format "%[fx:1/($amp0+1)]" info:`
  • cyc=`convert xc: -format "%[fx:0.5+$numcycles]" info:`
  • convert \( -size 1x100 gradient: -rotate 90 \) \
    \( -clone 0 -function sinusoid $cyc,-90,0.5,0.5 \) \
    \( -clone 1 -evaluate multiply $amp1 \) \
    \( -clone 0 -evaluate multiply $amp2 \) \
    -delete 0,1 -compose plus -composite $tmpA2
  • convert \( $tmpA1 -colorspace gray -blur 0x$smooth \
    -shade ${azimuth}x${elevation} -auto-level \) \
    $tmpA2 -clut $outfile