Fred's ImageMagick Scripts



 

 

DISPERSE


Applies a dispersion effect to an image.

Download Script

last modified: May 30, 2008



USAGE: disperse [-s scale] [-a amount] [-g granularity] infile outfile
USAGE: disperse [-h or -help]

-s scale scale factor; integer>0; default=5
-a amount amount of dispersion; integer>0; default=5
-g granularity granularity of dispersion; integer>0; default=5

PURPOSE: To apply a dispersion effect to an image.

DESCRIPTION: DISPERSE applies a dispersion effect to an image by using a random displacement map.

ARGUMENTS:

-s scale ... SCALE factor for dispersion. Values are integers>0. Typical values range from 2 to 20. The default=5

-a amount ... AMOUNT of dispersion. Values are integers>0. Typical values range from 2 to 20. The default=5

-g granularity ... GRANULARITY of dispersion. Values are integers>0. Typical values range from 2 to 20. The default=5

NOTE: The script uses -fx and may be a little slow.

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


Disperse
http://www.jhlabs.com/ip/filters/

Original

Arguments:
-s 2 -a 2 -g 2

Arguments:
-s 2 -a 2 -g 5

Arguments:
-s 2 -a 2 -g 10

Arguments:
-s 5 -a 5 -g 2

Arguments:
-s 5 -a 5 -g 5

Arguments:
-s 5 -a 5 -g 10

Arguments:
-s 10 -a 10 -g 2

Arguments:
-s 10 -a 10 -g 5

Arguments:
-s 10 -a 10 -g 10

Arguments:
-s 10 -a 20 -g 2

Arguments:
-s 10 -a 20 -g 5

Arguments:
-s 10 -a 20 -g 10

Arguments:
-s 20 -a 10 -g 2

Arguments:
-s 20 -a 10 -g 5

Arguments:
-s 20 -a 10 -g 10



What the script does is as follows:

  • Creates a random, blurred displacement map
  • Applies the displacement map to the image using a trig function

This is equivalent to the following IM commands

  • ww=`convert $infile -format "%[fx:w]" info:`
  • hh=`convert $infile -format "%[fx:h]" info:`
  • convert -size ${ww}x${hh} xc: +noise Random -virtual-pixel tile \
    -blur 0x${granularity} -fx intensity -contrast-stretch 0% $tmp0
  • convert $infile $tmp0 -monitor \
    -fx "xx=i+$scale*sin($amount*v*2*pi); yy=j+$scale*cos($amount*v*2*pi); u.p{xx,yy}" \
    $outfile