Fred's ImageMagick Scripts



    Licensing:

    My scripts are available free of charge for non-commercial use.

    If you redistribute or incorporate any of these scripts into other free applications, you may use my scripts by simply referencing my name and this web page: Fred Weinhaus and http://www.fmwconcepts.com/imagemagick/index.html

    For use of my scripts in commercial use or non-free applications, please contact me for licensing arrangements.
    My email address is fmw at alink dot net.

    Usage, whether stated in script or not, is also subject 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 06, 2012



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