Fred's ImageMagick Scripts



 

 

DISPERSE


Applies a dispersion effect to an image.

Download Script

last modified: November 27, 2011



USAGE: disperse [-s scale] [-d amount] [-c granularity] infile outfile
USAGE: disperse [-h or -help]

-s .... spread ........... spread distance of dispersion; integer>0; default=5
-d .... density .......... density or frequency of detail; integer>0; default=5
-c .... curviness ........ curviness/clumpiness of dispersion; integer>=0; default=5
.......................... low values produce fine dust-like detail;
.......................... larger values produce larger clumpy/curvy clusters;
-r .... reseed ........... forced seed value; integer>0; default will randomly change seed

PURPOSE: To apply a dispersion effect to an image.

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

ARGUMENTS:

-s spread ... SPREAD distance of dispersion. Values are integers>0. Typical values range from 2 to 20. The default=5

-d density ... DENSITY is the closeness or frequency of detail. Values are integers>0. The default=5.

-c curviness ... CURVINESS/CLUMPINESS of dispersion. Values are integers>=0. Small values produce fine, dust-like detail. Larger values produce more clumpy and curvy clusters. Typical values range from 0 to 20. The default=5

-r reseed ... RESEED is the forced seed value to use for randomization. This permits the pattern to be repeated. The default is to change the seed value randomly each time the script is run, thus causing somewhat different patterns each time the script is run.

NOTE: For IM prior to 6.4.8-5, 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 -d 2 -c 2

Arguments:
-s 2 -d 2 -c 5

Arguments:
-s 2 -d 2 -c 10

Arguments:
-s 5 -d 5 -c 2

Arguments:
-s 5 -d 5 -c 5

Arguments:
-s 5 -d 5 -c 10

Arguments:
-s 10 -d 10 -c 2

Arguments:
-s 10 -d 10 -c 5

Arguments:
-s 10 -d 10 -c 10

Arguments:
-s 10 -d 20 -c 2

Arguments:
-s 10 -d 20 -c 5

Arguments:
-s 10 -d 20 -c 10

Arguments:
-s 20 -d 10 -c 2

Arguments:
-s 20 -d 10 -c 5

Arguments:
-s 20 -d 10 -c 10



Fire Effect
Original Image And Idea From Anthony Thyssen

Original

Arguments:
-s 20 -d 2 -c 5

Arguments:
-s 20 -d 2 -c 5



Textured Glass Effect

Original

Arguments:
-s 3 -d 3 -c 3

Original

Arguments:
-s 3 -d 3 -c 3



What the script does is as follows:

  • Creates a random, blurred displacement map
  • Applies the displacement map to the image using a sinusoidal 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${curviness} -fx intensity -contrast-stretch 0% $tmp0
  • convert $infile $tmp0 -monitor \
    -fx "xx=i+$spread*sin($density*v*2*pi); yy=j+$spread*cos($density*v*2*pi); u.p{xx,yy}" \
    $outfile