User Tools

Site Tools


diverse:commandline:smoothhisto

Smooth Histogram

Description

If an arbitrary number of bins is used to generate a histogram from an integer data-type image, spikes can arise due to an uneven number of integer values within each bin. This utility converts images to floating point and adds random noise with values between 0 and 1 before calculating the histogram

Author

Jonathan Jackson (jjackson a.t familyjackson dot net)

Change List

  • 2008-12-04: First uploaded to ImageJ Wiki

Usage

Usage: histogram [options] image

Purpose:  Generates smooth histograms with a user-specified number of bins.

Options:
  -a<n>         set min and max automatically (mean +- 2*sd)
                n is an optional parameter to change the number of sd's
  -l <hMin>     histogram min (lower) value
  -m            set min and max to the min and max values in the image
  -n <nBins>    number of bins in histogram (default=256)
                if n <= 1 then the bin width is set to 1 (ie. nBins = max-min)
  -u <hMax>     histogram max (upper) value
  -z            include pixels with values <= 0

Advanced Options:
  -s            don't add 0-1 random noise for smoother histogram
                (this eliminates spikes and is on by default when bin width != 1)

Input files may be in Analyze, NIFTI, DICOM or UNC format
The output has three columns: 'Bin number' 'Bin start' 'Number of Pixels'

Installation

Dependencies:

Finally, save the wrapper script (to ImageJ/bin/histogram), make the file executable and edit paths as appropriate:

#!/bin/bash
 
class="Smooth_Histogram"
 
ij_path="/usr/local/ImageJ/"
ij_plugins="${ij_path}plugins"
 
java_path="/usr/java/jdk1.5/bin/"
 
CLASSPATH="${ij_path}ij.jar"
CLASSPATH="${CLASSPATH}:${ij_plugins}/Histogram/"
CLASSPATH="${CLASSPATH}:${ij_plugins}/jars/getopt.jar"
export CLASSPATH
 
shopt -s xpg_echo
RED='\e[1;31m'
NC='\e[0m' # no color
if [[ -z "$DISPLAY" ]] ; then
    echo "${RED}$(basename $0) may fail because the DISPLAY variable is not set properly${NC}" 1>&2
    echo "Try using 'ssh -Y' when you log in to a remote machine" 1>&2
fi
 
shopt -s extglob
eval im_file='${'$#'}'  # last argument should be the image file
mem=$(${ij_path}bin/estimate_mem -m 4 -b 32 $im_file) # need space for image in 32bit, so possible 4x 8bit -> 32 bit conversion
 
${java_path}java -mx${mem}m -Dplugins.dir=${ij_path} -Dscript.name=`basename $0`  $class $@
exit $?
diverse/commandline/smoothhisto.txt · Last modified: 2019/04/12 13:13 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki