Package org.esa.snap.core.util.math
Class Histogram
java.lang.Object
org.esa.snap.core.util.math.Range
org.esa.snap.core.util.math.Histogram
Instances of the
Histogram class store histogram data.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final floatstatic final float -
Constructor Summary
ConstructorsConstructorDescriptionHistogram(int[] binCounts, double min, double max) Constructs a new instance for the given bin counts and the given value range. -
Method Summary
Modifier and TypeMethodDescriptionvoidaggregate(Object values, boolean unsigned, IndexValidator validator, ProgressMonitor pm) static HistogramcomputeHistogram(RenderedImage image, javax.media.jai.ROI roi, int numBins, Range range) static HistogramcomputeHistogramByte(byte[] values, IndexValidator validator, int numBins, Range range, Histogram histo, ProgressMonitor pm) Computes the histogram for the values in the givenbytearray in the given value range.static HistogramcomputeHistogramDouble(double[] values, IndexValidator validator, int numBins, Range range, Histogram histogram, ProgressMonitor pm) Computes the histogram for the values in the givendoublearray in the given value range.static HistogramcomputeHistogramDouble(DoubleList values, IndexValidator validator, int numBins, Range range, Histogram histo, ProgressMonitor pm) Computes the histogram for the values in the givenHistogram.DoubleListin the given value range.static HistogramcomputeHistogramFloat(float[] values, IndexValidator validator, int numBins, Range range, Histogram histogram, ProgressMonitor pm) Computes the histogram for the values in the givenfloatarray in the given value range.static HistogramcomputeHistogramGeneric(Object values, boolean unsigned, IndexValidator validator, int numBins, Range range, Histogram histogram, ProgressMonitor pm) Computes the histogram for the values in the givenHistogram.DoubleListin the given value range.static HistogramcomputeHistogramInt(int[] values, IndexValidator validator, int numBins, Range range, Histogram histogram, ProgressMonitor pm) Computes the histogram for the values in the givenintarray in the given value range.static HistogramcomputeHistogramShort(short[] values, IndexValidator validator, int numBins, Range range, Histogram histo, ProgressMonitor pm) Computes the histogram for the values in the givenshortarray in the given value range.static HistogramcomputeHistogramUByte(byte[] values, IndexValidator validator, int numBins, Range range, Histogram histo, ProgressMonitor pm) Computes the histogram for the values in the givenbytearray in the given value range.static HistogramcomputeHistogramUInt(int[] values, IndexValidator validator, int numBins, Range range, Histogram histogram, ProgressMonitor pm) Computes the histogram for the values in the givenintarray in the given value range.static HistogramcomputeHistogramUShort(short[] values, IndexValidator validator, int numBins, Range range, Histogram histo, ProgressMonitor pm) Computes the histogram for the values in the givenshortarray in the given value range.findRange(double leftHistoAreaSkipped, double rightHistoAreaSkipped) Returns the value range for the case that the given ratios of the sum of all bin values are skipped from the lower and upper bounds of this histogram.findRange(double leftHistoAreaSkipped, double rightHistoAreaSkipped, boolean skipLeftPeek, boolean skipRightPeek) Returns the value range for the case that 2.5% of the sum of all bin values are skipped from the the lower and upper bounds of this histogram.findRangeForPercent(double threshold) Returns the value range for any threshold of 0% to 100% where the sum of all bin values are skipped from the the lower and upper bounds of this histogram.int[]Gets the bin values of this histogram.intGets the sum of all countsintgetBinIndex(double value) Gets the bin index for the given value.intGets the maximum bin value found this histogram.intGets the number of bins in this histogram.getRange(int binIndex) Gets the data value range for the given bin index.getRange(int binIndex1, int binIndex2) Gets the data value range for the given bin index range.voidsetBinCounts(int[] binCounts) Sets the bin values of this histogram.voidsetBinCounts(int[] binValues, double min, double max) Sets the bin values and range of this histogram.Methods inherited from class org.esa.snap.core.util.math.Range
computeRangeByte, computeRangeDouble, computeRangeDouble, computeRangeDouble, computeRangeFloat, computeRangeGeneric, computeRangeInt, computeRangeShort, computeRangeUByte, computeRangeUInt, computeRangeUShort, getMax, getMin, isValid, setMax, setMin, setMinMax, toString
-
Field Details
-
LEFT_AREA_SKIPPED_95
public static final float LEFT_AREA_SKIPPED_95- See Also:
-
RIGHT_AREA_SKIPPED_95
public static final float RIGHT_AREA_SKIPPED_95- See Also:
-
-
Constructor Details
-
Histogram
public Histogram(int[] binCounts, double min, double max) Constructs a new instance for the given bin counts and the given value range.- Parameters:
binCounts- the bin countsmin- the minimum valuemax- the maximum value
-
-
Method Details
-
getNumBins
public int getNumBins()Gets the number of bins in this histogram.- Returns:
- the number of bins
-
getBinCounts
public int[] getBinCounts()Gets the bin values of this histogram.- Returns:
- the bin values
-
setBinCounts
public void setBinCounts(int[] binValues, double min, double max) Sets the bin values and range of this histogram.- Parameters:
binValues- the bin valuesmin- the minimum value of the rangemax- the maximum value of the range
-
setBinCounts
public void setBinCounts(int[] binCounts) Sets the bin values of this histogram.- Parameters:
binCounts- the bin values
-
getMaxBinCount
public int getMaxBinCount()Gets the maximum bin value found this histogram.- Returns:
- the maximum bin value
-
getBinCountsSum
public int getBinCountsSum()Gets the sum of all counts- Returns:
- the sum of all counts.
-
findRangeFor95Percent
Returns the value range for the case that 2.5% of the sum of all bin values are skipped from the the lower and upper bounds of this histogram.- Returns:
- the skipped value range, that include 95% of the sum of all bin values
-
findRangeForPercent
Returns the value range for any threshold of 0% to 100% where the sum of all bin values are skipped from the the lower and upper bounds of this histogram.- Returns:
- the skipped value range, that include given percent of the sum of all bin values
-
findRange
Returns the value range for the case that the given ratios of the sum of all bin values are skipped from the lower and upper bounds of this histogram.- Parameters:
leftHistoAreaSkipped- the normalized area (a ratio of the entire area) of samples skipped from the left end of the histogram, must be greater than or equal to0.0and less than1.0 - rightHistoAreaSkippedrightHistoAreaSkipped- the normalized area (a ratio of the entire area) of samples skipped from the upper end of the histogram must be greater than or equal to0.0and less than1.0 - leftHistoAreaSkipped- Returns:
- the readjusted range
-
findRange
public Range findRange(double leftHistoAreaSkipped, double rightHistoAreaSkipped, boolean skipLeftPeek, boolean skipRightPeek) -
getRange
Gets the data value range for the given bin index.- Parameters:
binIndex- the bin index- Returns:
- the data value range
-
getRange
Gets the data value range for the given bin index range.- Parameters:
binIndex1- the first bin indexbinIndex2- the second bin index- Returns:
- the data value range
-
getBinIndex
public int getBinIndex(double value) Gets the bin index for the given value.- Parameters:
value- the value- Returns:
- the bin index or
-1if the value is not covered by this histogram.
-
aggregate
public void aggregate(Object values, boolean unsigned, IndexValidator validator, ProgressMonitor pm) -
computeHistogramByte
public static Histogram computeHistogramByte(byte[] values, IndexValidator validator, int numBins, Range range, Histogram histo, ProgressMonitor pm) Computes the histogram for the values in the givenbytearray in the given value range. The array elements are interpreted as signed byte values. Values at a given indexifor whichvalidator.validate(i)returnsfalseare excluded from the computation.- Parameters:
values- the array whose histogram to computevalidator- used to validate the array indexes, must not benull. UseIndexValidator.TRUEinstead.numBins- the number of bins for the histogramrange- the value range, ifnullthe range is automatically computedpm- a monitor to inform the user about progress- Returns:
- the histogram for the given array
- See Also:
-
computeHistogramUByte
public static Histogram computeHistogramUByte(byte[] values, IndexValidator validator, int numBins, Range range, Histogram histo, ProgressMonitor pm) Computes the histogram for the values in the givenbytearray in the given value range. The array elements are interpreted as unsigned byte values. Values at a given indexifor whichvalidator.validate(i)returnsfalseare excluded from the computation.- Parameters:
values- the array whose histogram to computevalidator- used to validate the array indexes, must not benull. UseIndexValidator.TRUEinstead.numBins- the number of bins for the histogramrange- the value range, ifnullthe range is automatically computedpm- a monitor to inform the user about progress- Returns:
- the histogram for the given array
- See Also:
-
computeHistogramShort
public static Histogram computeHistogramShort(short[] values, IndexValidator validator, int numBins, Range range, Histogram histo, ProgressMonitor pm) Computes the histogram for the values in the givenshortarray in the given value range. The array elements are interpreted as signed short values. Values at a given indexifor whichvalidator.validate(i)returnsfalseare excluded from the computation.- Parameters:
values- the array whose histogram to computevalidator- used to validate the array indexes, must not benull. UseIndexValidator.TRUEinstead.numBins- the number of bins for the histogramrange- the value range, ifnullthe range is automatically computed- Returns:
- the histogram for the given array
- See Also:
-
computeHistogramUShort
public static Histogram computeHistogramUShort(short[] values, IndexValidator validator, int numBins, Range range, Histogram histo, ProgressMonitor pm) Computes the histogram for the values in the givenshortarray in the given value range. The array elements are interpreted as unsigned short values. Values at a given indexifor whichvalidator.validate(i)returnsfalseare excluded from the computation.- Parameters:
values- the array whose histogram to computevalidator- used to validate the array indexes, must not benull. UseIndexValidator.TRUEinstead.numBins- the number of bins for the histogramrange- the value range, ifnullthe range is automatically computedpm- a monitor to inform the user about progress- Returns:
- the histogram for the given array
- See Also:
-
computeHistogramInt
public static Histogram computeHistogramInt(int[] values, IndexValidator validator, int numBins, Range range, Histogram histogram, ProgressMonitor pm) Computes the histogram for the values in the givenintarray in the given value range. The array elements are interpreted as signed byte values. Values at a given indexifor whichvalidator.validate(i)returnsfalseare excluded from the computation.- Parameters:
values- the array whose histogram to computevalidator- used to validate the array indexes, must not benull. UseIndexValidator.TRUEinstead.numBins- the number of bins for the histogramrange- the value range, ifnullthe range is automatically computedhistogram- a histogram instance to be reused, can benullpm- a monitor to inform the user about progress- Returns:
- the histogram for the given array
- See Also:
-
computeHistogramUInt
public static Histogram computeHistogramUInt(int[] values, IndexValidator validator, int numBins, Range range, Histogram histogram, ProgressMonitor pm) Computes the histogram for the values in the givenintarray in the given value range. The array elements are interpreted as unsigned byte values. Values at a given indexifor whichvalidator.validate(i)returnsfalseare excluded from the computation.- Parameters:
values- the array whose histogram to computevalidator- used to validate the array indexes, must not benull. UseIndexValidator.TRUEinstead.range- the value range, ifnullthe range is automatically computedhistogram- a histogram instance to be reused, can benullpm- a monitor to inform the user about progress- Returns:
- the histogram for the given array of values
- See Also:
-
computeHistogramFloat
public static Histogram computeHistogramFloat(float[] values, IndexValidator validator, int numBins, Range range, Histogram histogram, ProgressMonitor pm) Computes the histogram for the values in the givenfloatarray in the given value range. Values at a given indexifor whichvalidator.validate(i)returnsfalseare excluded from the computation.- Parameters:
values- the array whose histogram to computevalidator- used to validate the array indexes, must not benull. UseIndexValidator.TRUEinstead.numBins- the number of bins for the histogramrange- the value range, ifnullthe range is automatically computedhistogram- a histogram instance to be reused, can benullpm- a monitor to inform the user about progress- Returns:
- the histogram for the given array of values
- See Also:
-
computeHistogramDouble
public static Histogram computeHistogramDouble(double[] values, IndexValidator validator, int numBins, Range range, Histogram histogram, ProgressMonitor pm) Computes the histogram for the values in the givendoublearray in the given value range. Values at a given indexifor whichvalidator.validate(i)returnsfalseare excluded from the computation.- Parameters:
values- the array whose histogram to computevalidator- used to validate the array indexes, must not benull. UseIndexValidator.TRUEinstead.numBins- the number of bins for the histogramrange- the value range, ifnullthe range is automatically computedhistogram- a histogram instance to be reused, can benullpm- a monitor to inform the user about progress- Returns:
- the histogram for the given array of values
- See Also:
-
computeHistogramDouble
public static Histogram computeHistogramDouble(DoubleList values, IndexValidator validator, int numBins, Range range, Histogram histo, ProgressMonitor pm) Computes the histogram for the values in the givenHistogram.DoubleListin the given value range. Values at a given indexifor whichvalidator.validate(i)returnsfalseare excluded from the computation.- Parameters:
values- theHistogram.DoubleListwhose histogram to computevalidator- used to validate the indexes, must not benull. UseIndexValidator.TRUEinstead.numBins- the number of bins for the histogramrange- the value range, ifnullthe range is automatically computedpm- a monitor to inform the user about progress- Returns:
- the histogram for the given values
- See Also:
-
computeHistogramGeneric
public static Histogram computeHistogramGeneric(Object values, boolean unsigned, IndexValidator validator, int numBins, Range range, Histogram histogram, ProgressMonitor pm) Computes the histogram for the values in the givenHistogram.DoubleListin the given value range. Values at a given indexifor whichvalidator.validate(i)returnsfalseare excluded from the computation.- Parameters:
values- theHistogram.DoubleListwhose histogram to computevalidator- used to validate the indexes, must not benull. UseIndexValidator.TRUEinstead.numBins- the number of bins for the histogramrange- the value range, ifnullthe range is automatically computedpm- a monitor to inform the user about progress- Returns:
- the histogram for the given values
- See Also:
-
computeHistogram
public static Histogram computeHistogram(RenderedImage image, javax.media.jai.ROI roi, int numBins, Range range)
-