For a given ENVIRaster object, this function returns statistics. The basic statistics that will be returned are the minimum, maximum, mean, number or pixels and standard deviation for all bands. The HISTOGRAM keyword can be set to get one histogram per input band. The histogram will include minimum, maximum, bin count, band, binsize, and pixel counts. The COVARIANCE keyword can be set on multi-band images to get the covariance matrix, eigenvectors, and eigenvalues.

Example


; Launch the application
e = ENVI()
 
; Create ENVIRaster statistics
file = FILEPATH('qb_boulder_msi', ROOT_DIR=e.ROOT_DIR, $
  SUBDIRECTORY = ['data'])
raster = e.OpenRaster(file)
 
; Return the statistics
stats = ENVIRasterStatistics(raster)
 
; Print out statistics individually
print, 'Minimum:'
foreach minValue, stats.min, index do $
print, 'Band ', index.ToString(), ':', minValue
 
print, 'Maximum:'
foreach maxValue, stats.max, index do $
print, 'Band ', index.ToString(), ':', maxValue
 
print, 'Standard Deviation:'
foreach stddevValue, stats.stddev, index do $
print, 'Band ', index.ToString(), ':', stddevValue
 
print, 'Mean:'
foreach meanValue, stats.Mean, index do $
print, 'Band ', index.ToString(), ':', meanValue

Syntax


Result = ENVIRasterStatistics( Data [, /COVARIANCE] [, ERROR=variable] [, /HISTOGRAMS] [, HISTOGRAM_BINSIZE=value] [, HISTOGRAM_MAX=value] [, HISTOGRAM_MIN=value] [, HISTOGRAM_NBINS=value])

Return Value


This method returns statistics for an ENVIRaster object.

The variable returned is a dictionary that contains the following keys:

MIN

STDDEV

CORRELATION

HISTOGRAMS

MAX

EIGENVALUES

MEAN

NPIXELS

EIGENVECTORS

COVARIANCE

If you have not specified the HISTOGRAM keyword, then HISTOGRAMS key value is !null.

If you have not specified the COVARIANCE keyword, then CORRELATION, EIGENVALUES, EIGENVECTORS, and COVARIANCE key values are !null.

HISTOGRAMS key value returns a list that contains dictionaries for each histogram band. Each dictionary contains the following keys:

MIN

BINCOUNT

BAND

MAX

COUNTS

BINSIZE

Keywords


Keywords are applied only during the initial creation of the object.

COVARIANCE

Set this keyword to get the covariance matrix, correlation, eigenvectors, and eigenvalues on multi-band images.

ERROR

Set this keyword to a named variable that will contain any error message issued during execution of this routine. If no error occurs, the ERROR variable will be set to a null string (''). If an error occurs and the routine is a function, then the function result will be undefined.

When this keyword is not set and an error occurs, ENVI returns to the caller and execution halts. In this case, the error message is contained within !ERROR_STATE and can be caught using IDL's CATCH routine. See IDL Help for more information on !ERROR_STATE and CATCH.

See Manage Errors for more information on error handling in ENVI programming.

HISTOGRAMS

Set this keyword to get one histogram value per band. If HISTOGRAMS is set, you can specify optional values for HISTOGRAM_BINSIZE, HISTOGRAM_MAX, and HISTOGRAM_MIN, HISTOGRAM_NBINS.

HISTOGRAM_BINSIZE

If HISTOGRAMS is set, specify a value for the bin size, to manage the resolution of the histogram. For example, to see the full histogram, set the HISTOGRAM_BINSIZE=1 to get as many bins as there are data range. If the data range is 20 to 1265, the result will be 1,246 separate bins per band, with a count of how many data pixels had that exact value. Another example with the same data is HISTOGRAM_NBINS=200. The bin size for that result will be approximately 6, where the first bin will contain the count for data ranging from 20 to 25, the next bin will contain data ranging from 26 to 31, and so on. If HISTOGRAM_BINSIZE or HISTOGRAM_NBINS are not specified, a value of 256 bins will be used on all bands. HISTOGRAM_BINSIZE is mutually exclusive with HISTOGRAM_NBINS.

HISTOGRAM_MAX

If HISTOGRAMS is set, specify a value for the maximum number of bins to include in the histogram for each band. Values specified as scalar will be applied to all bands (for example, HISTOGRAM_MAX=1000, to calculate histograms of the same size for all bands). Values specified as an array will be applied to individual bands (for example, HISTOGRAM_MAX=[200,500,1000,10000] for a four-band image, to calculate histograms over a different range of values for each band). If HISTOGRAM_MAX is not specified, the data maximum of the band will be used.

HISTOGRAM_MIN

If HISTOGRAMS is set, specify a value for the minimum number of bins to include in the histogram for each band. Values specified as scalar will be applied to all bands (for example, HISTOGRAM_MIN=0, to calculate histograms of the same size for all bands). Values specified as an array will be applied to individual bands (for example, HISTOGRAM_MIN=[0, 20, 50,100] for a four-band image, to calculate histograms over a different range of values for each band). If HISTOGRAM_MIN is not specified, the data minimum of the band will be used.

HISTOGRAM_NBINS

If HISTOGRAMS is set, specify a value to limit the histogram to a certain number of bins. If HISTOGRAM_NBINS or HISTOGRAM_BINSIZE are not specified, a value of 256 will be used on all bands. HISTOGRAM_NBINS is mutually exclusive with HISTOGRAM_BINSIZE.

Version History


ENVI 5.2

Introduced

API Version


4.2

See Also


ENVIRaster, RasterStatistics Task, RasterHistogram Task