Fred's ImageMagick Scripts



    Licensing:

    Copyright © Fred Weinhaus

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

    Please read the Pointers For Use on my home page to properly install and customize my scripts.

POLARBLUR


Applies a polar blur to an image.

Download Script

last modified: December 15, 2018



USAGE: polarblur [-r radial ] [-a angular] infile outfile
USAGE: polarblur [-h or -help]

-r ... radial .... radial blur amount; float≥0; default=10
-a ... angular ... angular blur amount; float≥0; default=0

PURPOSE: To apply a polar blur to an image.

DESCRIPTION: POLARBLUR applies a polar blur to an image. The blur direction may be either or both radial or angular. The processing is a gaussian-like blur performed in the polar domain. A cartesian to polar transform is first applied, then the blur, then a polar to cartesian transform is applied.

ARGUMENTS:

-r radial ... RADIAL is the radial blur amount in pixels. Values are floats≥0. The default=10. A value of zero means no radial blur.

-a angular ... ANGULAR is the angular blur amount in degrees. Values are floats≥0. The default=0. A value of zero means no radial blur.

REQUIREMENTS: IM 6.5.9.3 is required due to the use of -morphology convolve blur.

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


Radial Blur

Original Image

Arguments:
-r 10 -a 0

Arguments:
-r 20 -a 0

Arguments:
-r 30 -a 0



Angular Blur

Original Image

Arguments:
-r 0 -a 10

Arguments:
-r 0 -a 20

Arguments:
-r 0 -a 30



Polar Blur

Original Image

Arguments:
-r 10 -a 10

Arguments:
-r 20 -a 20

Arguments:
-r 30 -a 30



What the script does is as follows:

  • converts the image from cartesian to polar coordinates
  • applies the blur in one dimension or the other or both
  • converts the image back to cartesian coordinates

This is equivalent to the following IM commands

  • ww=`convert -ping "$infile" -format "%w" info:`
  • hh=`convert -ping "$infile" -format "%h" info:`
  • rsigma=`convert xc: -format "%[fx:$radial/3]" info:`
  • asigma=`convert xc: -format "%[fx:(360/$ww)*$angular/5]" info:`
  • if [ "$angular" = "0" -a "$radial" != "0" ]; then
    convert "$infile" -virtual-pixel edge -distort DePolar -1 \
    -morphology Convolve Blur:0x${rsigma},90 \
    -virtual-pixel HorizontalTile -background black -distort Polar -1 "$outfile"

    elif [ "$angular" != "0" -a "$radial" = "0" ]; then
    convert "$infile" -virtual-pixel edge -distort DePolar -1 \( +clone \) \( +clone \) +append \
    -morphology Convolve Blur:0x${asigma} \
    -gravity center -crop ${ww}x${hh}+0+0 +repage \
    -virtual-pixel HorizontalTile -background black -distort Polar -1 "$outfile"

    elif [ "$angular" != "0" -a "$radial" != "0" ]; then
    convert "$infile" -virtual-pixel edge -distort DePolar -1 \( +clone \) \( +clone \) +append \
    -morphology Convolve Blur:0x${rsigma},90 \
    -morphology Convolve Blur:0x${asigma} \
    -gravity center -crop ${ww}x${hh}+0+0 +repage \
    -virtual-pixel HorizontalTile -background black -distort Polar -1 "$outfile"
    fi