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

WAVEMAP


Transforms the graylevels in each RGB channel according to a sinusoidal wave function.

Download Script

last modified: May 07, 2015



USAGE: wavemap [-c cycles] [-p phase] infile outfile
USAGE: wavemap [-h or -help]

-c .... cycles ..... number of cycles in sinusiodal wave transform;
.................... float>=0; default=0.5
-p .... phase ...... phase shift from cosine function; 0<=float<=360;
.................... default=0

PURPOSE: To transform the graylevels in each RGB channel according to a sinusoidal wave function.

DESCRIPTION: WAVEMAP transform the graylevels in each RGB channel according to a sinusoidal wave function. This is similar to GIMP's Alien Map.

ARGUMENTS:

-c cycle ... CYCLES is the number of cycles in the sinusoidal wave transform. Values are floats>=0. One or three comma delimited values may be provided, one for each of the RGB channels. If only the one value is provided, the other two will be set to the same value. The default=0.5 (which is the same as 0.5,0.5,0.5). With phase=0, this produces a nearly linear transform.

-p phase ... PHASE is the phase shift in degrees from a cosine wave. Values are in the range 0<=float<=360. One or three comma delimited values may be provided, one for each of the RGB channels. If only the one value is provided, the other two will be set to the same value. The default=0 (or 0,0,0) will produce a cosine wave. See http://www.imagemagick.org/Usage/transform/#function_sinusoid. In wavemap, we will add 90 degrees to the phase value so that the sinusoid will be shifted from a sine to a cosine wave as the default. With cycles=0.5, this produces a nearly linear transform.

REQUIREMENT: IM version 6.4.8-9 or higher due to the use of -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


Original Image
(http://phong.informatik.uni-leipzig.de/~kuska/oglscript/EarthMap.png)

 

Arguments:
-c 0.5 -p 0
(default)

 

Arguments:
-c 0.5 -p 30

 

Arguments:
-c 0.7,0.5,0.5 -p 0

 

Arguments:
-c 0.3,0.5,0.5 -p 0

 

Arguments:
-c 0.5,0,0 -p 0

 

Arguments:
-c 1 -p 0


What the script does is as follows:

  • Converts the image to RGB colorspace and separates the channels
  • Applies -function sinusoidal "cycles,phase" to each channel
  • Combines the channels back to an RGB image

This is equivalent to the following IM commands.

  • convert $infile -colorspace rgb -channel red -separate +channel +repage $tmpR1
  • convert $infile -colorspace rgb -channel green -separate +channel +repage $tmpG1
  • convert $infile -colorspace rgb -channel blue -separate +channel +repage $tmpB1
  • pr=`convert xc: -format "%[fx:$pr-90]" info:`
  • pg=`convert xc: -format "%[fx:$pg-90]" info:`
  • pb=`convert xc: -format "%[fx:$pb-90]" info:`
  • convert $tmpR1 -function sinusoid "$cr,$pr" $tmpR1
  • convert $tmpG1 -function sinusoid "$cg,$pb" $tmpG1
  • convert $tmpB1 -function sinusoid "$cb,$pb" $tmpB1
  • convert $tmpR1 $tmpG1 $tmpB1 -combine $outfile