|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.xinapse.multisliceimage.Histogram
public class Histogram
A class for creating and finding statistics about arrays of pixel intensities, histograms of pixel intensities, and statistics about those histograms.
| Nested Class Summary | |
|---|---|
static class |
Histogram.BinSpec
A specification for Histogram bins. |
| Constructor Summary | |
|---|---|
Histogram(double[] count,
double histoMin,
double binWidth)
Creates a Histogram of intensities from pre-computed values. |
|
Histogram(Histogram h)
Creates a new Histogram, copying all values from an existing Histogram. |
|
Histogram(java.lang.Object pixelValues,
int offset,
int nPixels,
PixelDataType dataType)
Creates a Histogram of intensities from an array of values. |
|
Histogram(java.lang.Object pixelValues,
int offset,
int nPixels,
PixelDataType dataType,
ComplexMode complexMode)
Creates a Histogram of intensities from an array of values, with an option to specifiy the mode of calculation for PixelDataType.COMPLEX, or PixelDataType.DOUBLECOMPLEX images. |
|
Histogram(java.lang.Object pixelValues,
int offset,
int nPixels,
PixelDataType dataType,
double min,
double max,
ComplexMode complexMode)
Creates a Histogram of intensities from an array of values over a specified intensity range. |
|
Histogram(java.lang.Object pixelValues,
int offset,
int nPixels,
PixelDataType dataType,
double min,
double max,
double binWidth,
ComplexMode complexMode)
Creates a Histogram of intensities from an array of values over a specified intensity range, and width a specified bin width. |
|
Histogram(java.lang.Object pixelValues,
int offset,
int nPixels,
PixelDataType dataType,
double min,
double max,
int nBins,
ComplexMode complexMode)
Creates a Histogram of intensities from an array of values over a specified intensity range, and with the specified number of bins. |
|
Histogram(java.lang.Object pixelValues,
PixelDataType dataType)
Creates a Histogram of intensities from an array of values. |
|
Histogram(java.lang.Object pixelValues,
PixelDataType dataType,
ComplexMode complexMode)
Creates a Histogram of intensities from an array of values. |
|
| Method Summary | |
|---|---|
Histogram |
add(Histogram histo,
PixelDataType dataType)
Adds the counts from a Histogram to this Histogram to produce a new Histogram that spans the data range of both. |
void |
addValues(java.lang.Object pixelValues,
int offset,
int nPixels,
PixelDataType dataType,
ComplexMode complexMode)
Adds some pixel values to this Histogram. |
static Histogram.BinSpec |
calcBins(double min,
double max,
int nBins,
PixelDataType dataType,
ComplexMode complexMode)
Calculates a suitable bin width, and minimum bin value for a histogram, given the for given type of pixels over the given intensity range. |
static Histogram.BinSpec |
calcBins(double min,
double max,
PixelDataType dataType,
ComplexMode complexMode)
Calculates a suitable bin width, number of bins, and minimum bin value for a histogram, given the for given type of pixels over the given intensity range. |
double |
getAreaUnder()
Returns the total area under this histogram. |
double |
getAreaUnder(boolean excludeZero)
Returns the area under this histogram, optionally excluding any zero-intensity pixels. |
double |
getBinWidth()
Returns the bin width for this Histogram. |
double |
getCount(int binIndex)
Returns the count in one bin of this Histogram. |
Histogram |
getCumulativeHistogram()
Return a new Histogram that is the cumulative histogram of this one. |
double |
getCumulativeIntensity(float fraction,
boolean excludeZero)
Returns an intensity value such that the specified fraction of pixels is below the returned intensity; zero-valued pixels are optionally excluded from the calculation. |
double |
getEntropy()
Returns the entropy of this Histogram. |
double |
getHistoMax(PixelDataType dataType)
Returns the maximum value that can be added to this Histogram's bins. |
double |
getHistoMin()
Returns the minimum bin value of this Histogram. |
static Histogram |
getInstance(LoadableImage image)
Creates a Histogram of intensities from a com.xinapse.loadableimage.LoadableImage. |
double |
getMean()
Returns the mean intensity value of this Histogram. |
double |
getMean(boolean excludeZero)
Returns the mean intensity value of this Histogram, optionally excluding all pixel intensities that are zero. |
double |
getMedian()
Returns the median value of this Histogram. |
double |
getMedian(boolean excludeZero)
Returns the median value of this Histogram, optionally excluding all pixel intensities that are zero. |
static double[] |
getMinMax(java.lang.Object pixelValues,
int offset,
int nPixels,
PixelDataType dataType,
ComplexMode complexMode)
Returns the minimum and maximum intensity values present in a part of an array of pixel values. |
static double[] |
getMinMax(java.lang.Object pixelValues,
PixelDataType dataType,
ComplexMode complexMode)
Returns the minimum and maximum intensity values present in an array of pixel values. |
int |
getNBins()
Returns the number of bins in this Histogram. |
double |
getPeakHeight(boolean excludeZero)
Returns the number of pixels with the most common pixel intensity in this Histogram, optionally excluding the pixel intensities that are zero-valued. |
double |
getPeakPosition(boolean excludeZero)
Returns the most common pixel intensity in this Histogram, optionally excluding the pixel intensities that are zero-valued. |
double |
getSD()
Returns the standard deviation of intensity values of this Histogram. |
double |
getSD(boolean excludeZero)
Returns the standard deviation of intensity values of this Histogram, optionally excluding all pixel intensities that are zero from the calculation. |
double |
getTotalCount()
Returns the total number of pixels that contributed to this histogram. |
double |
getTotalCount(boolean excludeZero)
Returns the total number of pixels that contributed to this histogram, optionally excluding any zero-intensity pixels. |
double |
getTotalCount(double threshold)
Returns the number of pixels in this histogram that are above the supplied threshold. |
static void |
main(java.lang.String[] args)
Run the self-test of the Histogram class. |
void |
normalise()
Normalises this Histogram, so that the sum of all the counts is unity. |
void |
setCount(int binIndex,
double count)
Sets the count in one bin of this Histogram. |
java.lang.String |
toString()
Returns a String that lists the min, max, bin width and count values of this Histogram. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Histogram(double[] count,
double histoMin,
double binWidth)
count - the number of pixels in each bin of the Histogram.histoMin - the intensity corresponding to the first bin of the Histogram.binWidth - the histogram bin width in intensity units.
public Histogram(java.lang.Object pixelValues,
PixelDataType dataType)
throws MultiSliceImageException
pixelValues - an array of pixel values for which the Histogram
will be created.dataType - the type of pixel value stored in the pixelValues.
MultiSliceImageException - if a Histogram cannot be created for
the supplied pixel data type, or if the intensity range in the pixels overflows that
which can be stored in the Histogram.
public Histogram(java.lang.Object pixelValues,
PixelDataType dataType,
ComplexMode complexMode)
throws MultiSliceImageException
pixelValues - an array of pixel values for which the Histogram
will be created.dataType - the type of pixel value stored in the pixelValues.complexMode - the ComplexMode for complex data types.
MultiSliceImageException - if a Histogram cannot be created for
the supplied pixel data type, or if the intensity range in the pixels overflows that
which can be stored in the Histogram.
public Histogram(java.lang.Object pixelValues,
int offset,
int nPixels,
PixelDataType dataType)
throws MultiSliceImageException
pixelValues - an array of pixel values for which the Histogram
will be created.offset - an offset (in pixels) into the array for the first pixel to be included
in the Histogram.nPixels - the number of pixels to be included in the Histogram.dataType - the type of pixel value stored in the pixelValues.
MultiSliceImageException - if a Histogram cannot be created for
the supplied pixel data type, or if the intensity range in the pixels overflows that
which can be stored in the Histogram.
public Histogram(java.lang.Object pixelValues,
int offset,
int nPixels,
PixelDataType dataType,
ComplexMode complexMode)
throws MultiSliceImageException
pixelValues - an array of pixel values for which the Histogram
will be created.offset - an offset (in pixels) into the array for the first pixel to be included
in the Histogram.nPixels - the number of pixels to be included in the Histogram.dataType - the type of pixel value stored in the pixelValues.complexMode - mode for calculation of the histogram of Complex images. For all other
types of image, the complexMode is ignored.
MultiSliceImageException - if a Histogram cannot be created for
the supplied pixel data type, or if the intensity range in the pixels overflows that
which can be stored in the Histogram.
public Histogram(java.lang.Object pixelValues,
int offset,
int nPixels,
PixelDataType dataType,
double min,
double max,
double binWidth,
ComplexMode complexMode)
throws MultiSliceImageException
pixelValues - an array of pixel values for which the Histogram
will be created.offset - an offset (in pixels) into the array for the first pixel to be included
in the Histogram.nPixels - the number of pixels to be included in the Histogram.dataType - the type of pixel value stored in the pixelValues.min - the intensity of the lowest-intensity bin of the Histogram.
Pixel intensities below the minimum are not included in the Histogram.
For PixelDataType.BINARY images this value must be 0.max - the intensity of the highest-intensity bin of the Histogram.
Pixel intensities above the maximum are not included in the Histogram.
For PixelDataType.BINARY images this value must be 1.binWidth - the bin width for the Histogram.complexMode - mode for calculation of the histogram of Complex images. For all other
types of image, the complexMode is ignored.
MultiSliceImageException - if a Histogram cannot be created for
the supplied pixel data type, or if the intensity range in the pixels overflows that
which can be stored in the Histogram.
public Histogram(java.lang.Object pixelValues,
int offset,
int nPixels,
PixelDataType dataType,
double min,
double max,
ComplexMode complexMode)
throws MultiSliceImageException
pixelValues - an array of pixel values for which the Histogram
will be created.offset - an offset (in pixels) into the array for the first pixel to be included
in the Histogram.nPixels - the number of pixels to be included in the Histogram.dataType - the type of pixel value stored in the pixelValues.min - the intensity of the lowest-intensity bin of the Histogram.
Pixel intensities below the minimum are not included in the Histogram.
For PixelDataType.BINARY images this value must be 0.max - the intensity of the highest-intensity bin of the Histogram.
Pixel intensities above the maximum are not included in the Histogram.
For PixelDataType.BINARY images this value must be 1.complexMode - mode for calculation of the histogram of Complex images. For all other
types of image, the complexMode is ignored.
MultiSliceImageException - if a Histogram cannot be created for
the supplied pixel data type, or if the intensity range in the pixels overflows that
which can be stored in the Histogram.
public Histogram(java.lang.Object pixelValues,
int offset,
int nPixels,
PixelDataType dataType,
double min,
double max,
int nBins,
ComplexMode complexMode)
throws MultiSliceImageException
pixelValues - an array of pixel values for which the Histogram
will be created.offset - an offset (in pixels) into the array for the first pixel to be included
in the Histogram.nPixels - the number of pixels to be included in the Histogram.dataType - the type of pixel value stored in the pixelValues.min - the intensity of the lowest-intensity bin of the Histogram.
Pixel intensities below the minimum are not included in the Histogram.
For PixelDataType.BINARY images this value must be 0.max - the intensity of the highest-intensity bin of the Histogram.
Pixel intensities above the maximum are not included in the Histogram.
For PixelDataType.BINARY images this value must be 1.nBins - the number of bins in the Histogram.complexMode - mode for calculation of the histogram of Complex images. For all other
types of image, the complexMode is ignored.
MultiSliceImageException - if the Histogram cannot be computed.public Histogram(Histogram h)
h - the Histogram from which the values will be copied.| Method Detail |
|---|
public static Histogram getInstance(LoadableImage image)
throws InvalidImageException
image - the image for which to find the Histogram.
InvalidImageException - if a Histogram
cannot be created for the supplied image, or if the intensity range in the pixels
overflows that which can be stored in the Histogram.
public void addValues(java.lang.Object pixelValues,
int offset,
int nPixels,
PixelDataType dataType,
ComplexMode complexMode)
throws MultiSliceImageException
pixelValues - an array of pixel values to add to the Histogram.offset - an offset (in pixels) into the array at which to start adding the
pixel values.nPixels - the number of pixels in the array to add.dataType - the type of pixel values to be added to this Histogram.complexMode - for calculation of the histogram for Complex images. For all other
types of image, the complexMode is ignored.
MultiSliceImageException - if pixels of this PixelDataType cannot be added
to this Histogram.public double getBinWidth()
public static Histogram.BinSpec calcBins(double min,
double max,
PixelDataType dataType,
ComplexMode complexMode)
throws MultiSliceImageException
min - the minimum intensity value.max - the maximum intensity value.dataType - the PixelDataType of the intensities.complexMode - the ComplexMode complex display mode for complex images.
MultiSliceImageException - if the bin width cannot be calculated for pixels with
the given minimum and maximum intensities (typically if the intensity range is infinite).
public static Histogram.BinSpec calcBins(double min,
double max,
int nBins,
PixelDataType dataType,
ComplexMode complexMode)
throws MultiSliceImageException
min - the minimum intensity value.max - the maximum intensity value.nBins - the number of bins for the Histogram.dataType - the PixelDataType of the intensities.complexMode - the ComplexMode complex display mode for complex images.
MultiSliceImageException - if the supplied bin width is unsuitable for this type
of PixelDataType, or if the given minimum and maximum intensities are outside the range for
this type of data.
public static double[] getMinMax(java.lang.Object pixelValues,
PixelDataType dataType,
ComplexMode complexMode)
throws MultiSliceImageException
pixelValues - an array of pixel values for which to find the minimum and maximum values.dataType - the type of pixel value stored in the pixelValues.complexMode - mode for the calculation of the minimum and maximum values for Complex
images. For all other types of image, the complexMode is ignored.
MultiSliceImageException - if a the minimum and maximum values cannot be found for
the supplied data type
public static double[] getMinMax(java.lang.Object pixelValues,
int offset,
int nPixels,
PixelDataType dataType,
ComplexMode complexMode)
throws MultiSliceImageException
pixelValues - an array of pixel values for which to find the minimum and maximum values.offset - an offset (in pixels) into the array for the first pixel to be included
in the calculation of min/max.nPixels - the number of pixels to be included in the calculation of min/max.dataType - the type of pixel value stored in the pixelValues.complexMode - mode for the calculation of the minimum and maximum values for Complex
images. For all other types of image, the complexMode is ignored.
MultiSliceImageException - if a the minimum and maximum values cannot be found for
the supplied data typepublic Histogram getCumulativeHistogram()
public int getNBins()
public double getCount(int binIndex)
binIndex - the index (zero-referenced) to the bin.
java.lang.IndexOutOfBoundsException - if binIndex is less than zero or greater than or equal to
the number of bins in the Hostogram.
public void setCount(int binIndex,
double count)
binIndex - the index (zero-referenced) to the bin.count - the number of counts to set in the Histogram bin.
java.lang.IndexOutOfBoundsException - if binIndex is less than zero or greater than or equal to
the number of bins in the Hostogram.public double getHistoMin()
public double getHistoMax(PixelDataType dataType)
For PixelDataTypes that represent whole (integer) numbers, this method returns the highest integer value that can be added to this histogram.
For floating-point (including double) this method returns the largest floating-point value that can be added to this histogram.
dataType - the PixelDataType for intensities to be added to this Histogram.
public double getPeakHeight(boolean excludeZero)
excludeZero - true if the zero-valued background is to be excluded
from the search for the most common intensity.
public double getPeakPosition(boolean excludeZero)
excludeZero - true if the zero-valued background is to be excluded
from the search for the most common intensity.
public double getMedian()
public double getMedian(boolean excludeZero)
excludeZero - true if the zero-valued background is to be excluded
from the calculation of the median.
public double getMean()
public double getMean(boolean excludeZero)
excludeZero - true if the zero-valued background is to be excluded
from the calculation of the mean.
public double getSD()
public double getSD(boolean excludeZero)
excludeZero - true if the zero-valued background is to be excluded
from the calculation of the standard deviation.
public double getCumulativeIntensity(float fraction,
boolean excludeZero)
fraction - the intensity value returned is such that this fraction of pixels is
below the returned intensity. Normally fraction would be between 0.0 and 1.0.
If fraction is less than or equal to 0.0, the minimum intensity is returned.
If fraction is greater than or equal to 1.0, the maximum intensity is returned.excludeZero - true if the zero-valued background is to be excluded
from the calculation of the intensity.
public Histogram add(Histogram histo,
PixelDataType dataType)
histo - the Histogram from which to add the counts.
public double getAreaUnder()
public double getAreaUnder(boolean excludeZero)
excludeZero - true if the zero-valued background is to be excluded
from the calculation of the area.
public double getTotalCount()
public double getTotalCount(boolean excludeZero)
excludeZero - true if the zero-valued background is to be excluded
from the pixel count.
public double getTotalCount(double threshold)
threshold - pixel intensity values that are below the threshold will be excluded
from the count.
public double getEntropy()
public void normalise()
public java.lang.String toString()
toString in class java.lang.Objectpublic static void main(java.lang.String[] args)
args - ignored.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||