MahalanobisDistanceClassification Task

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 properties (Set, Get): CLASS_COLORS, CLASS_NAMES, CLASS_PIXEL_COUNT, COVARIANCE, INPUT_RASTER, MEAN, OUTPUT_RASTER_URI, OUTPUT_RULE_RASTER_URI, THRESHOLD_MAX_DISTANCE

Output properties (Get only): OUTPUT_RASTER, OUTPUT_RULE_RASTER

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

Methods

This task inherits the following methods from ENVITask:

AddParameter

Execute

Parameter

ParameterNames

RemoveParameter

Properties

This task inherits the following properties from ENVITask:

COMMUTE_ON_DOWNSAMPLE

COMMUTE_ON_SUBSET

DESCRIPTION

DISPLAY_NAME

NAME

REVISION

TAGS

This task also contains the following properties:

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

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

OUTPUT_RASTER_URI (optional)

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

OUTPUT_RULE_RASTER

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

OUTPUT_RULE_RASTER_URI (optional)

Specify a string with the fully qualified filename and path of the associated OUTPUT_RASTER. If you do not specify this property, the associated OUTPUT_RASTER will not be created. To force the creation of a temporary file set the property to an exclamation symbol (!).

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.

Version History

ENVI 5.2

Introduced

API Version

4.2

See Also

ENVITask, MinimumDistanceClassification Task, MaximumLikelihoodClassification Task