de.unihalle.informatik.MiToBo.core.datatypes
Class MTBImageHistogram

java.lang.Object
  extended by de.unihalle.informatik.Alida.operator.ALDData
      extended by de.unihalle.informatik.MiToBo.core.datatypes.MTBImageHistogram

public class MTBImageHistogram
extends de.unihalle.informatik.Alida.operator.ALDData

Class for generating intensity histograms of MTBImages

Author:
glass

Field Summary
private  double[] data
          Array holding the histogram data
private  double highBound
          upper boundary of the last bin
private  int largestNonEmptyBin
          largest intensity value contained in the input image
private  double lowBound
          lower boundary of the first bin.
private  double numEntries
          number of histogram entries
private  int size
          number of bins
private  int smallestNonEmptyBin
          smallest intensity value contained in the input image
private  double sum
          sum of all histogram entries
 
Constructor Summary
MTBImageHistogram(double[] vals, int bins, double lowBoundary, double highBoundary)
          Construct new histogram from array of values.
MTBImageHistogram(MTBImage img)
          construct a new MTBHistogram object from the given MTBImage
number of bins is 256 and the histogram ranges from the smallest
image value to the largest image value
MTBImageHistogram(MTBImage img, int bins)
          construct a new MTBHistogram object from the given MTBImage
the histogram ranges from the smallest image value to the largest image value
MTBImageHistogram(MTBImage img, int bins, double lowBoundary, double highBoundary)
          construct a histogram for the given input image
with specification of binning and value range
all MTBImage types except RGB type are supported
MTBImageHistogram(MTBImage img, MTBImage mask, int bins, double lowBoundary, double highBoundary)
          construct a histogram for the given input image only for the pixels specified by a binary mask
all MTBImage types except RGB type are supported
with specification of binning and value range
 
Method Summary
 void add(MTBImageHistogram h)
          add histogram data to this MTBHistogram object.
 void binning(int bins)
          change the binning of the histogram
 void cumulate()
          calculate the cumulative histogram
 void cumulateOnly()
          calculate the cumulative histogram without changing the sum of absolute frequencies (normalizing factor), because cumulate() calls initialize() and thus destroys this normalizing factor
 int getBinIndex(double value)
          determines the index of the histogram bin, to which a value is assigned, if histogram value range and binning were specified at creation
 double getBinMidpoint(int binIndex)
          determines the value midpoint of a histogram bin for given bin index, if
histogram value range and binning were specified at creation
 double getBinValue(int i)
           
 double[] getData()
           
 int getLargestNonEmptyBin()
           
 double getMaxValue()
           
 double getMaxValueBin()
           
 double getMean()
           
 double getNumEntries()
           
 int getSize()
           
 int getSmallestNonEmptyBin()
           
 double getStdDev()
           
 double getSum()
           
 double getVariance()
           
private  void initialize()
          initialize histogram, i.e. determine smallest non empty bin, largest non
empty bin, number of histogram entries and sum of the histogram
 void logarithmize()
          calculate the logarithmic (base e) histogram; entries smaller than one become zero!
 double mapIndexToValue(int index)
           
 void normalize()
          normalize the histogram
 void normalizeOnly()
          normalize the histogram without changing the sum of absolute frequencies (normalizing factor), because normalize() calls initialize() and thus destroys this normalizing factor.
 void save(java.lang.String fileName)
          write the histogram data into a text file
 void setBinValue(int i, double val)
          set the bin value at i-th position
 java.lang.String toString()
           
 void truncate(int l, int r)
          truncate the histogram to the specified interval
 
Methods inherited from class de.unihalle.informatik.Alida.operator.ALDData
cloneProperties, getLocation, getProperty, getPropertyKeys, print, setLocation, setProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

data

private double[] data
Array holding the histogram data


highBound

private double highBound
upper boundary of the last bin


largestNonEmptyBin

private int largestNonEmptyBin
largest intensity value contained in the input image


lowBound

private double lowBound
lower boundary of the first bin.


numEntries

private double numEntries
number of histogram entries


size

private int size
number of bins


smallestNonEmptyBin

private int smallestNonEmptyBin
smallest intensity value contained in the input image


sum

private double sum
sum of all histogram entries

Constructor Detail

MTBImageHistogram

public MTBImageHistogram(double[] vals,
                         int bins,
                         double lowBoundary,
                         double highBoundary)
Construct new histogram from array of values.

Parameters:
vals - Values
bins - Number of bins.
lowBoundary - Lower boundary of first bin.
highBoundary - Upper boundary of last bin.

MTBImageHistogram

public MTBImageHistogram(MTBImage img)
construct a new MTBHistogram object from the given MTBImage
number of bins is 256 and the histogram ranges from the smallest
image value to the largest image value

Parameters:
img - MTBImage

MTBImageHistogram

public MTBImageHistogram(MTBImage img,
                         int bins)
construct a new MTBHistogram object from the given MTBImage
the histogram ranges from the smallest image value to the largest image value

Parameters:
img - MTBImage
bins - number of bins

MTBImageHistogram

public MTBImageHistogram(MTBImage img,
                         int bins,
                         double lowBoundary,
                         double highBoundary)
                  throws java.lang.IllegalArgumentException
construct a histogram for the given input image
with specification of binning and value range
all MTBImage types except RGB type are supported

Parameters:
img - input image for which the histogram is calculated
bins - number of histogram bins
lowBoundary - determines the lower boundary of the first bin
highBoundary - determines the upper boundary of the last bin
Throws:
java.lang.IllegalArgumentException - if an RGB image is given as input

MTBImageHistogram

public MTBImageHistogram(MTBImage img,
                         MTBImage mask,
                         int bins,
                         double lowBoundary,
                         double highBoundary)
                  throws java.lang.IllegalArgumentException
construct a histogram for the given input image only for the pixels specified by a binary mask
all MTBImage types except RGB type are supported
with specification of binning and value range

Parameters:
img - input image for which the histogram is calculated
mask - binary mask specifying which pixels are considered for the creation of the histogram
bins - number of histogram bins
lowBoundary - determines the lower boundary of the first bin
highBoundary - determines the upper boundary of the last bin
Throws:
java.lang.IllegalArgumentException - if an RGB image is given as input
Method Detail

add

public void add(MTBImageHistogram h)
         throws java.lang.IllegalArgumentException
add histogram data to this MTBHistogram object.

Parameters:
h - MTBHistogram to add
Throws:
java.lang.IllegalArgumentException

binning

public void binning(int bins)
change the binning of the histogram

Parameters:
bins - number of bins

cumulate

public void cumulate()
calculate the cumulative histogram


cumulateOnly

public void cumulateOnly()
calculate the cumulative histogram without changing the sum of absolute frequencies (normalizing factor), because cumulate() calls initialize() and thus destroys this normalizing factor


getBinIndex

public int getBinIndex(double value)
determines the index of the histogram bin, to which a value is assigned, if histogram value range and binning were specified at creation

Parameters:
value - image value
Returns:
index of histogram bin for a given value (indices range from 0 to (bins-1))

getBinMidpoint

public double getBinMidpoint(int binIndex)
determines the value midpoint of a histogram bin for given bin index, if
histogram value range and binning were specified at creation

Parameters:
binIndex - bin index
Returns:
(gray value) midpoint of a bin

getBinValue

public double getBinValue(int i)
Parameters:
i - position
Returns:
bin value of the ith bin

getData

public double[] getData()
Returns:
data values

getLargestNonEmptyBin

public int getLargestNonEmptyBin()
Returns:
largest non empty bin

getMaxValue

public double getMaxValue()
Returns:
largest value

getMaxValueBin

public double getMaxValueBin()
Returns:
bin with largest value

getMean

public double getMean()
Returns:
mean intensity value

getNumEntries

public double getNumEntries()
Returns:
number of entries

getSize

public int getSize()
Returns:
number of bins

getSmallestNonEmptyBin

public int getSmallestNonEmptyBin()
Returns:
smallest non empty bin

getStdDev

public double getStdDev()
Returns:
standard deviation of the intensity values

getSum

public double getSum()
Returns:
sum of entries

getVariance

public double getVariance()
Returns:
variance of the intensity values

initialize

private void initialize()
initialize histogram, i.e. determine smallest non empty bin, largest non
empty bin, number of histogram entries and sum of the histogram

Parameters:
h - initializing values in a double array

logarithmize

public void logarithmize()
calculate the logarithmic (base e) histogram; entries smaller than one become zero!


mapIndexToValue

public double mapIndexToValue(int index)
Parameters:
index -
Returns:
intensity value of the bin with index index

normalize

public void normalize()
normalize the histogram


normalizeOnly

public void normalizeOnly()
normalize the histogram without changing the sum of absolute frequencies (normalizing factor), because normalize() calls initialize() and thus destroys this normalizing factor.


save

public void save(java.lang.String fileName)
write the histogram data into a text file

Parameters:
fileName - file name for histogram data

setBinValue

public void setBinValue(int i,
                        double val)
set the bin value at i-th position

Parameters:
i - position
val - bin value

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

truncate

public void truncate(int l,
                     int r)
truncate the histogram to the specified interval

Parameters:
l - left border
r - right border