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.


Iteratively cleans noise from an image.

Download Script

last modified: December 15, 2018

USAGE: noisecleaner [-m method] [-n numiter] [-s stopdiff] [-f format]
[-p] infile outfile

USAGE: noisecleaner [-h or -help]

-m ... method ..... method of cleaning noise; choices are: 1 using
................... IM -enhance and 2 using IM -despeckle; default=1
-n ... numiter .... number of iterations; integer>0; default=5
-s ... stopdiff ... rmse stopping difference between between iterations;
................... 0<=float<=1; default=0 (do not stop until numiter reached)
-f ... format ..... output image format; choices are last (iteration) or
................... all (iterations); default=last
-p ................ show progress to terminal

PURPOSE: To iteratively clean noise from an image.

DESCRIPTION: NOISECLEANER iteratively cleans noise from an image. Two methods are available using either IM -enhance or IM -despeckle.


-m method ... METHOD method of cleaning noise. The choices are: 1 using IM -enhance and 2 using IM -despeckle. The default=1

-n numiter ... NUMITER is the number of iterations to apply. Values are integers>0. The default=5.

-s stopdiff ... STOPDIFF is the rmse stopping difference between between iterations. Values are 0<=floats<=1. The default=0 which indicates not to stop until numiter is reached. If a value larger than zero is specified, then processing will quit when the rmse difference between iterations is less than or equal to this value. Values larger than 0 will slow the processing in order to compute the rmse difference.

-f format ... FORMAT is the desired output image format. The choices are last (l), which saves only the last iteration reached or all (a), which saves a multiframe (multilayer) tiff file with each iteration as a frame (layer). The default is last. Note the output image file name will have its suffix replaced by .tif

-p ... show iteration PROGRESS to terminal

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 - Format = Last

(image with noise added via filmgrain script)

-m 1 -n 5

-m 2 -n 5

(stops at sixth iteration)
-m 1 -n 10 -s 0.005

(stops at seventh iteration)
-m 2 -n 10 -s 0.005

Example 2 - Format = All

(image with noise added via filmgrain script)

-m 1 -n 10 -f all
Animate Alternate Iterations

-m 2 -n 10 -f all
Animate Alternate Iterations

Example 3 - Bubbles With Noise

(image processed to even out background)

-m 1 -n 10 -f last
(no significant change after 10 iterations)

-m 2 -n 10 -f all
(Animate Alternate Iterations)

What the script does is as follows:

  • Iteratatively applies either -enhance for method=1 or -despeckle for method=2