Fred's ImageMagick Scripts


    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:

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


Creates an edge extracted image using the difference of two gaussian blurs.

Download Script

last modified: December 15, 2018

USAGE: dog [-s smallfilt] [-l largefilt] [-m mode] [-t thresh] [-b brighten] infile outfile
USAGE: dog [-h or -help]

-s .... smallfilt .... size of small gaussian filter; float>0; default=1
-l .... largefilt .... size of large gaussian filter; float>0; default=2
-m .... mode ......... mode of subtraction; choices are 1 (larger-smaller)
...................... and 2 (smaller - larger); default=1
-t .... thresh ....... edge tresholding value; 0<=integer<=100; The default
...................... is no thresholding; a value=0 is all edges thresholded
-b .... brighten ..... edge brightening factor; float>=1; default=1 is
...................... no brightening

PURPOSE: To create an edge extracted image using the difference of two gaussian blurs.

DESCRIPTION: DOG creates an edge extracted image using the difference of two gaussian blurs of different sizes.


-s smallfilt ... SMALLFILT is the size of the smaller gaussian blur filter. Values are floats>0. The default=1

-l largefilt ... LARGEFILT is the size of the larger gaussian blur filter. Values are floats>0. The default=1

-m mode ... MODE determines the order of the subtraction. Choices are: 1 for (larger - smaller) or 2 for (smaller - larger). The default=1.

-t thresh ... THRESH is the optional thresholding applied to the edge image to make the edges binary white on a black background. Values are 0<=integer<=100. The default indicates no thresholding. A value of 0 means threshold to get all edges.

-b brighten ... BRIGHTEN is the brightening factor for the edges. Values are floats>=1. The default=1 indicates no brightening.

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.


Example 1



-b 2

-b 2 -t 10

-b 2 -t 20

Example 2
(original image:


-s 1 -l 2

-s 1 -l 5

-s 3 -l 7

Example 3 -- Variation In Mode

-s 1 -l 2 -m 1

-s 1 -l 2 -m 2

-s 3 -l 7 -m 1

-s 3 -l 7 -m 2

What the script does is as follows:

  • Creates two different size gaussian blurred images
    and subtracts them

This is equivalent to the following IM commands

  • convert $infile \
    \( -clone 0 -blur 0x$largefilt \) \
    \( -clone 0 -blur 0x$smallfilt \) \
    -delete 0 +swap -compose minus -composite \
    -autolevel -evaluate multiply $brighten \
    -threshold $thresh% $outfile