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.

ISONOISE


Reduces isolated noise in an image

Download Script

last modified: December 15, 2018



USAGE: isonoise [-r radius] [-t threshold] infile outfile
USAGE: isonoise [-h or -help]

-r ............ radius ....... radius of filter; default=1

-t ............ threshold .... threshold percentage for separating noise from image (default=10)

PURPOSE: To reduce isolated noise in an image.

DESCRIPTION: ISONOISE is a noise filter designed to try to reduce impulse or isolated (sparce) noise in an image. It works by using the median filtered image where it assesses that noise is present and the original image where it assesses that no noise is present.

ARGUMENTS:

-r ... radius ..... radius is an integer >=1. It determines the neighborhood of pixels to use to compute the median at each pixel in the image. A radius=1 means use a 3x3 neighborhood about each pixel. A radius=2 means use a 5x5 neighborhood about each pixel. The larger the radius, the longer the processing and the more blurring that will occur. Noise filters generally trade some degree or blurring for noise reduction.

-t ... threshold .. threshold is in percent (without % symbol) and determines how much of the image is assessed to be noise. A smaller threshold, will reduce noise more effectively but cause more blurring. On the other hand, a larger threshold will reduce noise less effectively, but cause less blurring.

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


Isolated Noise Removal From A Grayscale Image

Original Grayscale Image

Isolated Random Noise

Isonoise Filtered Image
Arguments: -r 1 -t 8

Noisy Grayscale Image



Comparison Animation Of Grayscale Image



Noise Removal Comparison With Original (non-noisy) Image
(perfect noise removal would be flat gray)

Compare Original
vs
Isonoise Filter Result

RMSE: 1106.79 (0.0168885)

Comparison Original
vs
Median Filter Result

RMSE: 1598.28 (0.0243882)

Compare Original
vs
Isonoise Filter Result

(normalize image)

Comparison Original
vs
Median Filter Result

(normalize image)



What the script does is as follows:

  • Performs median filtering on the image
  • Computes the difference image between the noisy and median filtered images.
  • Thresholds the difference image to try to locate the areas of noise.
  • Composites the original image and the median filtered image
    such that the result using the median filtered image where
    there is noise and the original image where there is no noise.

This is equivalent to the following IM commands:

  • convert $infile -median $radius $tmp0
  • convert $infile $tmp0 -compose Difference -composite -threshold $thresh% $tmp1
  • convert $infile $tmp0 $tmp1 -compose src -composite $outfile