public class SHisto extends Object
Constructor and Description |
---|
SHisto(int[] numBins,
double[] lowValue,
double[] highValue)
Constructor.
|
SHisto(int[] numBins,
double[] lowValue,
double[] highValue,
int numBands)
Constructor.
|
SHisto(int numBins,
double lowValue,
double highValue,
int numBands)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
clearHistogram()
Resets the values of all bins to zero.
|
double |
getBinLowValue(int band,
int bin)
Returns the lowest inclusive pixel value of a given bin for a specific
band.
|
double[][] |
getBins()
Returns the array of bands of bins, each bin is the histogram for a band,
i.e., the format of the returned array is
int[bands][bins] . |
double[] |
getBins(int band)
Returns the bins of the histogram for a specific band by reference.
|
double[] |
getBinsFirstBand()
Returns the bins of the first band.
|
double |
getBinsFirstBand(int j)
Returns the bin content of the first band.
|
double |
getBinSize(int band,
int bin)
Returns the number of pixel samples found in a given bin for a specific
band.
|
double[] |
getEntropy()
Returns the entropy of the histogram.
|
SHisto |
getGaussianSmoothed(double standardDeviation)
Computes a Gaussian smoothed version of the histogram.
|
double[] |
getHighValue()
Returns the highest exclusive pixel value checked for all bands.
|
double |
getHighValue(int band)
Returns the highest value checked for a specific band.
|
double[] |
getIterativeThreshold()
Calculates the threshold using iterative bisection.
|
double[] |
getLowValue()
Returns the lowest inclusive pixel value checked for all bands.
|
double |
getLowValue(int band)
Returns the lowest inclusive pixel value checked for a specific band.
|
double[] |
getMaxEntropyThreshold()
Calculates the threshold which maximizes the entropy.
|
double[] |
getMaxVarianceThreshold()
Calculates the threshold which maximizes the ratio of the between-class
variance to the within-class variance for each band.
|
double[] |
getMean()
Returns the mean values for all bands of the histogram.
|
double[] |
getMinErrorThreshold()
Calculates the threshold which minimizes the probability of error.
|
double[] |
getMinFuzzinessThreshold()
Calculates the threshold which minimizes the fuzziness.
|
double[] |
getModeThreshold(double power)
Calculates the threshold using the mode method.
|
double[] |
getMoment(int moment,
boolean isAbsolute,
boolean isCentral)
Returns a specified (absolute) (central) moment of the histogram.
|
int |
getNumBands()
Returns the number of bands of the histogram.
|
int[] |
getNumBins()
Returns the number of bins of the histogram for all bands.
|
int |
getNumBins(int band)
Returns the number of bins of the histogram for a specific band.
|
double[] |
getPTileThreshold(double p)
Calculates the p-tile threshold.
|
SHisto |
getSmoothed(boolean isWeighted,
int k)
Computes a smoothed version of the histogram.
|
double[] |
getStandardDeviation()
Returns the standard deviation for all bands of the histogram.
|
int |
getSubTotal(int band,
int minBin,
int maxBin)
Returns the total bin count for the specified sub-range (via "min" and
"max" bin) of the indicated band.
|
int[] |
getTotals()
Returns the total bin count over all bins for all bands.
|
void |
setBins(double[] xbin)
Set bin values assuming that there only one band
|
void |
setBins(double[][] xbin)
Set bin values
|
public SHisto(int[] numBins, double[] lowValue, double[] highValue)
This constructor should be used when numBins
,
lowValue
, and/or highValues
are different
for each band of the image. The length of the arrays indicates the number
of bands the image has, and the three arrays must have the same length.
Since this constructor has no way of knowing the actual number of bands of the image, the length of the arrays is not checked against anything. Therefore, it is very important that the caller supplies the correct arrays of correct lengths, or errors will occur.
numBins
- The number of bins for each band of the image. The length of
this array indicates the number of bands for this histogram.lowValue
- The lowest inclusive pixel value checked for each band.highValue
- The highest exclusive pixel value checked for each band.public SHisto(int[] numBins, double[] lowValue, double[] highValue, int numBands)
This constructor should be used when numBins
,
lowValue
, and/or highValues
may be
different for each band of the image. The number of bands in the image is
provided explicitly. If any of the arrays provided has a length which is
less than the number of bands, the first element in that array is used to
fill out the array to a length of numBands
.
numBins
- The number of bins for each band of the image.lowValue
- The lowest value checked for each band.highValue
- The highest value checked for each band.numBands
- The number of bands in the image.public SHisto(int numBins, double lowValue, double highValue, int numBands)
The same numBins
, lowValue
, and
highValue
is applied to every band of the image.
numBins
- The number of bins for all bands of the image.lowValue
- The lowest inclusive pixel value checked for all bands.highValue
- The highest exclusive pixel value checked for all bands.numBands
- The number of bands of the image.public int[] getNumBins()
public int getNumBins(int band)
band
- The index of the band whose numBins
is to be
returned.public double[] getLowValue()
public double getLowValue(int band)
band
- The index of the band whose lowValue
is to be
returned.public double[] getHighValue()
public double getHighValue(int band)
band
- The index of the band whose highValue
is to be
returned.public int getNumBands()
bins.length
.public double[][] getBins()
int[bands][bins]
.public void setBins(double[][] xbin)
xbin
- bin values for a specific bandpublic void setBins(double[] xbin)
xbin
- bin values for a specific bandpublic double[] getBins(int band)
band
- The index of the band whose bins
are to be
returned.public double[] getBinsFirstBand()
bins
- from the first bandpublic double getBinsFirstBand(int j)
bin
- indexpublic double getBinSize(int band, int bin)
band
- The index of the band-of-interest.bin
- The index of the bin whose value is to be returned.public double getBinLowValue(int band, int bin)
band
- The index of the band-of-interest.bin
- The index of the bin whose lowValue
is to be
returned.public void clearHistogram()
bins
has not
been initialized (null
), this method does nothing.public int[] getTotals()
An array which stores the total bin count is kept in this class and a
reference to this array is returned by this method for performance
reasons. The elements of the returned array should not be modified or
undefined errors may occur. The array format is
int[numBands]
.
public int getSubTotal(int band, int minBin, int maxBin)
band
- The index of the band-of-interest.minBin
- The minimum bin index to be counted.maxBin
- The maximum bin index to be counted.public double[] getMean()
public double[] getMoment(int moment, boolean isAbsolute, boolean isCentral)
The ith moment in each band is defined to be the mean of the image pixel values raised to the ith power in that band. For central moments the average of the ith power of the deviation from the mean is used. For absolute moments the absolute value of the exponentiated term is used.
Note that the mean is the first moment, the average energy the second central moment, etc.
moment
- The moment number or index which must be positive or an
IllegalArgumentException
will be thrown.isAbsolute
- Whether to calculate the absolute moment.isCentral
- Whether to calculate the central moment.public double[] getStandardDeviation()
public double[] getEntropy()
The histogram entropy is defined to be the negation of the sum of the products of the probability associated with each bin with the base-2 log of the probability.
public SHisto getSmoothed(boolean isWeighted, int k)
Each band of the histogram is smoothed by averaging over a moving window of a size specified by the method parameter: if the value of the parameter is k then the width of the window is 2*k + 1. If the window runs off the end of the histogram only those values which intersect the histogram are taken into consideration. The smoothing may optionally be weighted to favor the central value using a "triangular" weighting. For example, for a value of k equal to 2 the central bin would have weight 1/3, the adjacent bins 2/9, and the next adjacent bins 1/9.
isWeighted
- Whether bins will be weighted using a triangular weighting
scheme favoring bins near the central bin.k
- The smoothing parameter which must be non-negative or an
IllegalArgumentException
will be thrown. If
zero, the histogram object will be returned with no smoothing
applied.public SHisto getGaussianSmoothed(double standardDeviation)
Each band of the histogram is smoothed by discrete convolution with a kernel approximating a Gaussian impulse response with the specified standard deviation.
standardDeviation
- The standard deviation of the Gaussian smoothing kernel which
must be non-negative or an
IllegalArgumentException
will be thrown. If
zero, the histogram object will be returned with no smoothing
applied.public double[] getPTileThreshold(double p)
Computes thresholds such that a specified proportion of the sample values in each band are below the threshold.
p
- The proportion of samples in each band which should be below
the threshold in the band. If p
is not in the
range (0.0, 1.0) an IllegalArgumentException
will be thrown.public double[] getModeThreshold(double power)
The threshold is defined to be the minimum between two peaks. The first peak is the highest peak in the histogram. The second peak is the highest peak in the histogram weighted by a specified power of the distance from the first peak.
power
- The exponent of the distance weighting from the first peak.public double[] getIterativeThreshold()
public double[] getMaxVarianceThreshold()
public double[] getMaxEntropyThreshold()
The entropy of a range of gray levels is defined to be the negation of the sum of products of the probability and the logarithm thereof over all gray levels in the range. The maximum entropy threshold is defined to be that value which maximizes the sum of the entropy of the two ranges which are above and below the threshold, respectively. This computation is effected for each band.
public double[] getMinErrorThreshold()
For each band the histogram is modeled as the sum of two Gaussian distributions and the threshold which minimizes the misclassification error is computed. If the underlying histogram is unimodal the mean value of each band will be returned as the threshold. The bimodality of the histogram for that band will be identically zero.
public double[] getMinFuzzinessThreshold()
Jas4pp 1.5 © Java Analysis Studio for Particle Physics