This task performs a Mahalanobis Distance supervised classification. Mahalanobis Distance is a direction-sensitive distance classifier that uses statistics for each class. It is similar to Maximum Likelihood classification, but it assumes all class covariances are equal and therefore is a faster method. All pixels are classified to the closest training data.

Example


; Start the application
e = ENVI()
 
; Open an input file
File = Filepath('qb_boulder_msi', Subdir=['data'], $
  Root_Dir=e.Root_Dir)
Raster = e.OpenRaster(File)
File2 = Filepath('qb_boulder_msi_vectors.shp', Subdir=['data'], $
  Root_Dir=e.Root_Dir)
Vector = e.OpenVector(File2)
 
; Get training statistics
StatTask = ENVITask('TrainingClassificationStatistics')
StatTask.INPUT_RASTER = Raster
StatTask.INPUT_VECTOR = Vector
StatTask.Execute
 
; Get the task from the catalog of ENVITasks
Task = ENVITask('MahalanobisDistanceClassification')
 
; Define inputs
Task.INPUT_RASTER = Raster
Task.COVARIANCE = StatTask.Covariance
Task.MEAN = StatTask.Mean
Task.CLASS_PIXEL_COUNT = StatTask.Class_Pixel_Count
 
; Run the task
Task.Execute
 
; Get the collection of data objects currently available in the Data Manager
DataColl = e.Data
 
; Add the output to the Data Manager
DataColl.Add, Task.OUTPUT_RASTER
 
; Display the result
View = e.GetView()
Layer = View.CreateLayer(Task.OUTPUT_RASTER)

Syntax


Result = ENVITask('MahalanobisDistanceClassification')

Input parameters (Set, Get): CLASS_COLORS, CLASS_NAMES, CLASS_PIXEL_COUNT, COVARIANCE, INPUT_RASTER, MEAN, OUTPUT_RASTER_URI, OUTPUT_RULE_RASTER_URI, REGULARIZATION_METHOD, REGULARIZATION_TOLERANCE, THRESHOLD_MAX_DISTANCE

Output parameters (Get only): OUTPUT_RASTER, OUTPUT_RULE_RASTER

Parameters marked as "Set" are those that you can set to specific values. You can also retrieve their current values any time. Parameters marked as "Get" are those whose values you can retrieve but not set.

Input Parameters


CLASS_COLORS (optional)

This is an array of RGB triplets representing the class colors as defined by the input vector.

CLASS_NAMES (optional)

This is a string array of class names as defined by the input vector.

CLASS_PIXEL_COUNT (required)

Specify an array that is the number of pixels per class: [number of classes].

COVARIANCE (required)

Specify an array that is [number of bands, number of bands, number of classes].

INPUT_RASTER (required)

Specify a raster on which to perform supervised classification.

MEAN (required)

Specify an array that is [number of bands, number of classes].

OUTPUT_RASTER_URI (optional)

Specify a string with the fully qualified filename and path to export the associated OUTPUT_RASTER.

  • If you do not specify this parameter, the OUTPUT_RASTER will not be created.
  • If you set this parameter to an asterisk symbol (*), the OUTPUT_RASTER will be virtual and not written to disk.
  • To force the creation of a temporary file, set this parameter to an exclamation symbol (!).
  • If you set it to the hash symbol (#), ENVI creates a file in the temporary directory, but this file will not be deleted when ENVI closes.

OUTPUT_RULE_RASTER_URI (optional)

Specify a string with the fully qualified filename and path of the associated OUTPUT_RULE_RASTER.

  • If you do not specify this parameter, the OUTPUT_RULE_RASTER will not be created.
  • To force the creation of a temporary file set the parameter to an exclamation symbol (!).
  • If you set it to the hash symbol (#), ENVI creates a file in the temporary directory, but this file will not be deleted when ENVI closes.

REGULARIZATION_METHOD (optional)

Specify a method for regularizing the covariance matrix:

  • Diagonal: Diagonal loading, increasing all singular values by the tolerance value.
  • Dominant: Dominant mode rejection, setting singular values less than the tolerance value to their mean.
  • None: No regularization is used.
  • Shrink: Shrinkage of singular values based on the tolerance value.
  • Threshold: Singular values less than the tolerance value are set to the tolerance value.
  • Truncate (default): Singular values less than the tolerance value are set to zero.

REGULARIZATION_TOLERANCE (optional)

Specify the tolerance value to use for matrix regularization. If not set, the following values will be used based on the regularization method

  • Diagonal: Ten times the smallest nonzero singular value.
  • Dominant: The value prescribed by Gavish & Donoho.
  • None: N/A
  • Shrink: The Oracle Approximating Shrinkage (OAS) estimator.
  • Threshold: The largest singular value times the machine precision.
  • Truncate (default): The largest singular value times the machine precision.

THRESHOLD_MAX_DISTANCE (optional)

Specify a pixel value between 0 and 10000000 that applies to all classes, or specify an array of pixel values, one for each class. The number of array elements must equal the number of classes. Mahalanobis Distance accounts for possible non-spherical probability distributions. This value represents the distance within which a class must fall from the center or mean of the distribution for a class. The smaller the distance threshold, the more pixels that are unclassified.

Output Parameters


OUTPUT_RASTER

This is a reference to the output raster of filetype ENVI.

OUTPUT_RULE_RASTER

This is a reference to the output rule image of filetype ENVI.

This output will not be generated unless its associated URI input parameter is set.

Methods


Execute

Parameter

ParameterNames

Properties


DESCRIPTION

DISPLAY_NAME

NAME

REVISION

TAGS

Version History


ENVI 5.2

Introduced

ENVI 6.2

Added the REGULARIZATION_METHOD and REGULARIZATION_TOLERANCE parameters

See Also


ENVITask, MinimumDistanceClassification Task, MaximumLikelihoodClassification Task, Masking Support in ENVITasks