org.esa.beam.util.math
Class Histogram

java.lang.Object
  extended by org.esa.beam.util.math.Range
      extended by org.esa.beam.util.math.Histogram

public class Histogram
extends Range

Instances of the Histogram class store histogram data.

Author:
Norman Fomferra

Field Summary
static float LEFT_AREA_SKIPPED_95
           
static float RIGHT_AREA_SKIPPED_95
           
 
Constructor Summary
Histogram(int[] binCounts, double min, double max)
          Constructs a new instance for the given bin counts and the given value range.
 
Method Summary
 void aggregate(Object values, boolean unsigned, IndexValidator validator, com.bc.ceres.core.ProgressMonitor pm)
           
static Histogram computeHistogram(RenderedImage image, javax.media.jai.ROI roi, int numBins, Range range)
           
static Histogram computeHistogramByte(byte[] values, IndexValidator validator, int numBins, Range range, Histogram histo, com.bc.ceres.core.ProgressMonitor pm)
          Computes the histogram for the values in the given byte array in the given value range.
static Histogram computeHistogramDouble(double[] values, IndexValidator validator, int numBins, Range range, Histogram histogram, com.bc.ceres.core.ProgressMonitor pm)
          Computes the histogram for the values in the given double array in the given value range.
static Histogram computeHistogramDouble(DoubleList values, IndexValidator validator, int numBins, Range range, Histogram histo, com.bc.ceres.core.ProgressMonitor pm)
          Computes the histogram for the values in the given Histogram.DoubleList in the given value range.
static Histogram computeHistogramFloat(float[] values, IndexValidator validator, int numBins, Range range, Histogram histogram, com.bc.ceres.core.ProgressMonitor pm)
          Computes the histogram for the values in the given float array in the given value range.
static Histogram computeHistogramGeneric(Object values, boolean unsigned, IndexValidator validator, int numBins, Range range, Histogram histogram, com.bc.ceres.core.ProgressMonitor pm)
          Computes the histogram for the values in the given Histogram.DoubleList in the given value range.
static Histogram computeHistogramInt(int[] values, IndexValidator validator, int numBins, Range range, Histogram histogram, com.bc.ceres.core.ProgressMonitor pm)
          Computes the histogram for the values in the given int array in the given value range.
static Histogram computeHistogramShort(short[] values, IndexValidator validator, int numBins, Range range, Histogram histo, com.bc.ceres.core.ProgressMonitor pm)
          Computes the histogram for the values in the given short array in the given value range.
static Histogram computeHistogramUByte(byte[] values, IndexValidator validator, int numBins, Range range, Histogram histo, com.bc.ceres.core.ProgressMonitor pm)
          Computes the histogram for the values in the given byte array in the given value range.
static Histogram computeHistogramUInt(int[] values, IndexValidator validator, int numBins, Range range, Histogram histogram, com.bc.ceres.core.ProgressMonitor pm)
          Computes the histogram for the values in the given int array in the given value range.
static Histogram computeHistogramUShort(short[] values, IndexValidator validator, int numBins, Range range, Histogram histo, com.bc.ceres.core.ProgressMonitor pm)
          Computes the histogram for the values in the given short array in the given value range.
 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.
 Range findRange(double leftHistoAreaSkipped, double rightHistoAreaSkipped, boolean skipLeftPeek, boolean skipRightPeek)
           
 Range 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.
 int[] getBinCounts()
          Gets the bin values of this histogram.
 int getBinCountsSum()
          Gets the sum of all counts
 int getBinIndex(double value)
          Gets the bin index for the given value.
 int getMaxBinCount()
          Gets the maximum bin value found this histogram.
 int getNumBins()
          Gets the number of bins in this histogram.
 Range getRange(int binIndex)
          Gets the data value range for the given bin index.
 Range getRange(int binIndex1, int binIndex2)
          Gets the data value range for the given bin index range.
 void setBinCounts(int[] binCounts)
          Sets the bin values of this histogram.
 void setBinCounts(int[] binValues, double min, double max)
          Sets the bin values and range of this histogram.
 
Methods inherited from class org.esa.beam.util.math.Range
computeRangeByte, computeRangeDouble, computeRangeDouble, computeRangeFloat, computeRangeGeneric, computeRangeInt, computeRangeShort, computeRangeUByte, computeRangeUInt, computeRangeUShort, getMax, getMin, isValid, setMax, setMin, setMinMax, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LEFT_AREA_SKIPPED_95

public static final float LEFT_AREA_SKIPPED_95
See Also:
Constant Field Values

RIGHT_AREA_SKIPPED_95

public static final float RIGHT_AREA_SKIPPED_95
See Also:
Constant Field Values
Constructor Detail

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 counts
min - the minimum value
max - the maximum value
Method Detail

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 values
min - the minimum value of the range
max - 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

public Range 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

findRange

public 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.

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 to 0.0 and less than 1.0 - rightHistoAreaSkipped
rightHistoAreaSkipped - 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 to 0.0 and less than 1.0 - leftHistoAreaSkipped
Returns:
the readjusted range

findRange

public Range findRange(double leftHistoAreaSkipped,
                       double rightHistoAreaSkipped,
                       boolean skipLeftPeek,
                       boolean skipRightPeek)

getRange

public Range getRange(int binIndex)
Gets the data value range for the given bin index.

Parameters:
binIndex - the bin index
Returns:
the data value range

getRange

public Range getRange(int binIndex1,
                      int binIndex2)
Gets the data value range for the given bin index range.

Parameters:
binIndex1 - the first bin index
binIndex2 - 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 -1 if the value is not covered by this histogram.

aggregate

public void aggregate(Object values,
                      boolean unsigned,
                      IndexValidator validator,
                      com.bc.ceres.core.ProgressMonitor pm)
Overrides:
aggregate in class Range

computeHistogramByte

public static Histogram computeHistogramByte(byte[] values,
                                             IndexValidator validator,
                                             int numBins,
                                             Range range,
                                             Histogram histo,
                                             com.bc.ceres.core.ProgressMonitor pm)
Computes the histogram for the values in the given byte array in the given value range. The array elements are interpreted as signed byte values. Values at a given index i for which validator.validate(i) returns false are excluded from the computation.

Parameters:
values - the array whose histogram to compute
validator - used to validate the array indexes, must not be null. Use IndexValidator.TRUE instead.
numBins - the number of bins for the histogram
range - the value range, if null the range is automatically computed
pm - a monitor to inform the user about progress
Returns:
the histogram for the given array
See Also:
computeHistogramUByte(byte[], org.esa.beam.util.math.IndexValidator, int, org.esa.beam.util.math.Range, org.esa.beam.util.math.Histogram, com.bc.ceres.core.ProgressMonitor)

computeHistogramUByte

public static Histogram computeHistogramUByte(byte[] values,
                                              IndexValidator validator,
                                              int numBins,
                                              Range range,
                                              Histogram histo,
                                              com.bc.ceres.core.ProgressMonitor pm)
Computes the histogram for the values in the given byte array in the given value range. The array elements are interpreted as unsigned byte values. Values at a given index i for which validator.validate(i) returns false are excluded from the computation.

Parameters:
values - the array whose histogram to compute
validator - used to validate the array indexes, must not be null. Use IndexValidator.TRUE instead.
numBins - the number of bins for the histogram
range - the value range, if null the range is automatically computed
pm - a monitor to inform the user about progress
Returns:
the histogram for the given array
See Also:
computeHistogramByte(byte[], org.esa.beam.util.math.IndexValidator, int, org.esa.beam.util.math.Range, org.esa.beam.util.math.Histogram, com.bc.ceres.core.ProgressMonitor)

computeHistogramShort

public static Histogram computeHistogramShort(short[] values,
                                              IndexValidator validator,
                                              int numBins,
                                              Range range,
                                              Histogram histo,
                                              com.bc.ceres.core.ProgressMonitor pm)
Computes the histogram for the values in the given short array in the given value range. The array elements are interpreted as signed short values. Values at a given index i for which validator.validate(i) returns false are excluded from the computation.

Parameters:
values - the array whose histogram to compute
validator - used to validate the array indexes, must not be null. Use IndexValidator.TRUE instead.
numBins - the number of bins for the histogram
range - the value range, if null the range is automatically computed
Returns:
the histogram for the given array
See Also:
computeHistogramUShort(short[], org.esa.beam.util.math.IndexValidator, int, org.esa.beam.util.math.Range, org.esa.beam.util.math.Histogram, com.bc.ceres.core.ProgressMonitor)

computeHistogramUShort

public static Histogram computeHistogramUShort(short[] values,
                                               IndexValidator validator,
                                               int numBins,
                                               Range range,
                                               Histogram histo,
                                               com.bc.ceres.core.ProgressMonitor pm)
Computes the histogram for the values in the given short array in the given value range. The array elements are interpreted as unsigned short values. Values at a given index i for which validator.validate(i) returns false are excluded from the computation.

Parameters:
values - the array whose histogram to compute
validator - used to validate the array indexes, must not be null. Use IndexValidator.TRUE instead.
numBins - the number of bins for the histogram
range - the value range, if null the range is automatically computed
pm - a monitor to inform the user about progress
Returns:
the histogram for the given array
See Also:
computeHistogramShort(short[], org.esa.beam.util.math.IndexValidator, int, org.esa.beam.util.math.Range, org.esa.beam.util.math.Histogram, com.bc.ceres.core.ProgressMonitor)

computeHistogramInt

public static Histogram computeHistogramInt(int[] values,
                                            IndexValidator validator,
                                            int numBins,
                                            Range range,
                                            Histogram histogram,
                                            com.bc.ceres.core.ProgressMonitor pm)
Computes the histogram for the values in the given int array in the given value range. The array elements are interpreted as signed byte values. Values at a given index i for which validator.validate(i) returns false are excluded from the computation.

Parameters:
values - the array whose histogram to compute
validator - used to validate the array indexes, must not be null. Use IndexValidator.TRUE instead.
numBins - the number of bins for the histogram
range - the value range, if null the range is automatically computed
histogram - a histogram instance to be reused, can be null
pm - a monitor to inform the user about progress
Returns:
the histogram for the given array
See Also:
computeHistogramUInt(int[], org.esa.beam.util.math.IndexValidator, int, org.esa.beam.util.math.Range, org.esa.beam.util.math.Histogram, com.bc.ceres.core.ProgressMonitor)

computeHistogramUInt

public static Histogram computeHistogramUInt(int[] values,
                                             IndexValidator validator,
                                             int numBins,
                                             Range range,
                                             Histogram histogram,
                                             com.bc.ceres.core.ProgressMonitor pm)
Computes the histogram for the values in the given int array in the given value range. The array elements are interpreted as unsigned byte values. Values at a given index i for which validator.validate(i) returns false are excluded from the computation.

Parameters:
values - the array whose histogram to compute
validator - used to validate the array indexes, must not be null. Use IndexValidator.TRUE instead.
range - the value range, if null the range is automatically computed
histogram - a histogram instance to be reused, can be null
pm - a monitor to inform the user about progress
Returns:
the histogram for the given array of values
See Also:
computeHistogramInt(int[], org.esa.beam.util.math.IndexValidator, int, org.esa.beam.util.math.Range, org.esa.beam.util.math.Histogram, com.bc.ceres.core.ProgressMonitor)

computeHistogramFloat

public static Histogram computeHistogramFloat(float[] values,
                                              IndexValidator validator,
                                              int numBins,
                                              Range range,
                                              Histogram histogram,
                                              com.bc.ceres.core.ProgressMonitor pm)
Computes the histogram for the values in the given float array in the given value range. Values at a given index i for which validator.validate(i) returns false are excluded from the computation.

Parameters:
values - the array whose histogram to compute
validator - used to validate the array indexes, must not be null. Use IndexValidator.TRUE instead.
numBins - the number of bins for the histogram
range - the value range, if null the range is automatically computed
histogram - a histogram instance to be reused, can be null
pm - a monitor to inform the user about progress
Returns:
the histogram for the given array of values
See Also:
computeHistogramDouble(double[], org.esa.beam.util.math.IndexValidator, int, org.esa.beam.util.math.Range, org.esa.beam.util.math.Histogram, com.bc.ceres.core.ProgressMonitor)

computeHistogramDouble

public static Histogram computeHistogramDouble(double[] values,
                                               IndexValidator validator,
                                               int numBins,
                                               Range range,
                                               Histogram histogram,
                                               com.bc.ceres.core.ProgressMonitor pm)
Computes the histogram for the values in the given double array in the given value range. Values at a given index i for which validator.validate(i) returns false are excluded from the computation.

Parameters:
values - the array whose histogram to compute
validator - used to validate the array indexes, must not be null. Use IndexValidator.TRUE instead.
numBins - the number of bins for the histogram
range - the value range, if null the range is automatically computed
histogram - a histogram instance to be reused, can be null
pm - a monitor to inform the user about progress
Returns:
the histogram for the given array of values
See Also:
computeHistogramFloat(float[], org.esa.beam.util.math.IndexValidator, int, org.esa.beam.util.math.Range, org.esa.beam.util.math.Histogram, com.bc.ceres.core.ProgressMonitor)

computeHistogramDouble

public static Histogram computeHistogramDouble(DoubleList values,
                                               IndexValidator validator,
                                               int numBins,
                                               Range range,
                                               Histogram histo,
                                               com.bc.ceres.core.ProgressMonitor pm)
Computes the histogram for the values in the given Histogram.DoubleList in the given value range. Values at a given index i for which validator.validate(i) returns false are excluded from the computation.

Parameters:
values - the Histogram.DoubleList whose histogram to compute
validator - used to validate the indexes, must not be null. Use IndexValidator.TRUE instead.
numBins - the number of bins for the histogram
range - the value range, if null the range is automatically computed
pm - a monitor to inform the user about progress
Returns:
the histogram for the given values
See Also:
computeHistogramByte(byte[], org.esa.beam.util.math.IndexValidator, int, org.esa.beam.util.math.Range, org.esa.beam.util.math.Histogram, com.bc.ceres.core.ProgressMonitor)

computeHistogramGeneric

public static Histogram computeHistogramGeneric(Object values,
                                                boolean unsigned,
                                                IndexValidator validator,
                                                int numBins,
                                                Range range,
                                                Histogram histogram,
                                                com.bc.ceres.core.ProgressMonitor pm)
Computes the histogram for the values in the given Histogram.DoubleList in the given value range. Values at a given index i for which validator.validate(i) returns false are excluded from the computation.

Parameters:
values - the Histogram.DoubleList whose histogram to compute
validator - used to validate the indexes, must not be null. Use IndexValidator.TRUE instead.
numBins - the number of bins for the histogram
range - the value range, if null the range is automatically computed
pm - a monitor to inform the user about progress
Returns:
the histogram for the given values
See Also:
computeHistogramByte(byte[], org.esa.beam.util.math.IndexValidator, int, org.esa.beam.util.math.Range, org.esa.beam.util.math.Histogram, com.bc.ceres.core.ProgressMonitor)

computeHistogram

public static Histogram computeHistogram(RenderedImage image,
                                         javax.media.jai.ROI roi,
                                         int numBins,
                                         Range range)


Copyright © 2002-2013 Brockmann Consult GmbH. All Rights Reserved.