Fred's ImageMagick Scripts



    Licensing:

    Copyright © Fred Weinhaus

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

STDIMAGE


Computes a pixel-by-pixel standard deviation or variance image from multiple input images.

Download Script

last modified: April 25, 2015



USAGE: stdimage [-m mode] [-c] infile1 ... infileN outfile
USAGE: stdimage [-h or -help]

-m .... mode ...... output statistic; mode=s or std (for standard deviation)
................... or mode=v or var (for variance)
-c ................ apply contrast stretch to output

Note: all images must be the same size

PURPOSE: To compute a pixel-by-pixel standard deviation or variance image from multiple input images.

DESCRIPTION: STDIMAGE computes a pixel-by-pixel standard deviation or variance image from multiple input images.

ARGUMENTS:

-m mode ... MODE statistical measure generated in the output image. Choices are either mode=s or std (for standard deviation) or mode=v or var (for variance). The default=std.

-c ... Apply contrast stretch to output.

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


Standard Deviation Of Image Vs. Image With Noise

Image

Noisy Image

Arguments:
-m std -c



Standard Deviation Of Three Completely Different Images

Image 1

Image 2

Image 3

Arguments:
-m std -c



What the script does is as follows:

  • Merges all input images into a multi-frame miff image, $tmp0,
    from an array of files, ${fileArray[*]} converted to a list, $infilelist
  • Separates frames and computes standard deviation among all image
    for each pixel

This is equivalent to the following IM commands for
the case of standard deviation with contrast stretch

  • ww=`convert "${fileArray[0]}" -ping -format "%w" info:`
  • hh=`convert "${fileArray[0]}" -ping -format "%h" info:`
  • convert -size ${ww}x${hh} xc: $tmp0
  • for img in $infilelist; do
  • convert $tmp0 $img $tmp0
  • done
  • # note -gamma 0.5 is equivalent to squaring and -gamma 2 is equivalent to square root
  • convert \( $tmp0 -coalesce -delete 0 -gamma 0.5 -average \) \
    \( $tmp0 -coalesce -delete 0 -average -gamma 0.5 \) \
    +swap -compose minus -composite -gamma 2 -contrast-stretch 0 $outfile