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

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

Class for generating intensity histograms of objects from class MTBImage.

Author:
glass

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)
          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, 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()
           
 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(String fileName)
          write the histogram data into a text file
 void setBinValue(int i, double val)
          set the bin value at i-th position
 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
 

Constructor Detail

MTBImageHistogram

public MTBImageHistogram(MTBImage img,
                         int bins,
                         double lowBoundary,
                         double highBoundary)
                  throws 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:
IllegalArgumentException - if an RGB image is given as input

MTBImageHistogram

public MTBImageHistogram(MTBImage img,
                         MTBImage mask,
                         int bins,
                         double lowBoundary,
                         double highBoundary)
                  throws 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. A value of zeor in the mask image indicates this pixel not to be considered
bins - number of histogram bins
lowBoundary - determines the lower boundary of the first bin
highBoundary - determines the upper boundary of the last bin
Throws:
IllegalArgumentException - if an RGB image is given as input

MTBImageHistogram

public MTBImageHistogram(MTBImage img,
                         MTBImage mask,
                         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
mask - binary mask specifying which pixels are considered for the creation of the histogram
bins - number of bins

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)
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(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.
Method Detail

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

mapIndexToValue

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

setBinValue

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

Parameters:
i - position
val - bin value

getMaxValue

public double getMaxValue()
Returns:
largest value

getMaxValueBin

public double getMaxValueBin()
Returns:
bin with largest value

getMean

public double getMean()
Returns:
mean intensity value

getVariance

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

getStdDev

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

toString

public String toString()
Overrides:
toString in class Object

add

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

Parameters:
h - MTBHistogram to add
Throws:
IllegalArgumentException

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.


truncate

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

Parameters:
l - left border
r - right border

binning

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

Parameters:
bins - number of bins

logarithmize

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


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


getData

public double[] getData()
Returns:
data values

getSize

public int getSize()
Returns:
number of bins

getSmallestNonEmptyBin

public int getSmallestNonEmptyBin()
Returns:
smallest non empty bin

getLargestNonEmptyBin

public int getLargestNonEmptyBin()
Returns:
largest non empty bin

getSum

public double getSum()
Returns:
sum of entries

getNumEntries

public double getNumEntries()
Returns:
number of entries

save

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

Parameters:
fileName - file name for histogram data


Copyright © 2010–2015 Martin Luther University Halle-Wittenberg. All rights reserved.