Welcome to the Harris Geospatial product documentation center. Here you will find reference guides, help documents, and product libraries.


Harris Geospatial / Docs Center / ENVI API / Processing / ENVISpectralAngleMapperClassificationTask

ENVISpectralAngleMapperClassificationTask

ENVISpectralAngleMapperClassificationTask

This task performs a Spectral Angle Mapper (SAM) supervised classification. SAM is a physically based spectral classification that uses an n-D angle to match pixels to reference spectra. This task requires an input vector or ROI layer from which mean spectra are computed for all of the records.

Use ENVITrainingClassificationStatisticsTask to compute the mean spectra from vector layers.

Example


This example uses ENVITrainingClassificationStatisticsTask to compute the mean spectra of each record from a polygon shapefile. It passes the mean spectra to the SAM classification task, which creates a classification image from a QuickBird scene.

; Start the application
e = ENVI()
 
; Open an input raster and vector
File1 = Filepath('qb_boulder_msi', Subdir=['data'], $
  Root_Dir=e.Root_Dir)
Raster = e.OpenRaster(File1)
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('SpectralAngleMapperClassification')
 
; Define inputs
Task.INPUT_RASTER = Raster
Task.MEAN = StatTask.MEAN
 
; Define outputs
Task.OUTPUT_RASTER_URI = e.GetTemporaryFilename()
 
; 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
View1 = e.GetView()
Layer1 = View1.CreateLayer(Task.Output_Raster)

See More Examples for a code example that uses mean spectra from ROIs as input to SAM classification.

Syntax


Result = ENVITask('SpectralAngleMapperClassification')

Input properties (Set, Get): CLASS_COLORS, CLASS_NAMES, IGNORE_VALIDATE, INPUT_RASTER, MEAN, OUTPUT_RASTER_URI, OUTPUT_RULE_RASTER_URI, THRESHOLD_ANGLE

Output properties (Get only): DESCRIPTION, NAME, 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


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.

DESCRIPTION

This property describes the task.

IGNORE_VALIDATE (optional)

This property is now deprecated and has no effect on task behavior. All task property values are validated when they are set, and they throw an error with bad input.

INPUT_RASTER (required)

Specify a raster on which to perform supervised classification.

MEAN (required)

Specify an array of size [number of bands, number of classes], representing the mean spectra from the input training regions. You can use ENVITrainingClassificationStatisticsTask to compute the mean spectra.

NAME

This property contains the name of the task.

OUTPUT_RASTER

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

OUTPUT_RASTER_URI (optional)

Specify a string with the fully qualified filename and path of the output raster. If you do not specify this property, the output raster is only temporary. Once the raster has no remaining references, ENVI deletes the temporary file.

OUTPUT_RULE_RASTER (optional)

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 output rule image.

THRESHOLD_ANGLE (required)

Specify an array of values in radians between 0 and 1.5708 (π/2). The default value is 1.5708. You can specify a one-element array to use the same threshold value for all classes. Or, specify an n-element array (where n equals the number of classes), with separate threshold values for each class.

More Examples


The following example uses mean spectra from individual ROIs as input to SAM classification. The ROIs represent locations of known mineral types. The input image is an AVIRIS hyperspectral scene of Cuprite, Nevada, USA. The files used in this example are available on the ENVI Resource DVD in the hyperspectral folder or from our website. Download the files CupriteAVIRISSubset.dat and CupriteMineralROIs.xml to a directory on your system.

  1. Copy the following code into a new window of the IDL Editor and save it to a file named CupriteSAMExample.pro.
  2. Change the input data paths to the location of the files on your system.
  3. Compile and run the program.
PRO CupriteSAMExample
  COMPILE_OPT IDL2
   
  ; Start the application
  e = ENVI()
   
  ; Select input data
  File = 'CupriteAVIRISSubset.dat'
  CupriteRaster = e.OpenRaster(File)
   
  ROIFile = 'CupriteMineralROIs.xml'
  rois = e.OpenROI(ROIFile)
   
  ; Create a mask that includes the ROIs
  MeanArray = !NULL
   
  For i=0, N_ELEMENTS(rois)-1 DO BEGIN
    ROITask = ENVITask('ROIMaskRaster')
    ROITask.DATA_IGNORE_VALUE = 0
    ROITask.INPUT_MASK_ROI = rois[i]
    ROITask.INPUT_RASTER = CupriteRaster
    ROITask.Execute
   
    ; Compute the mean from each ROI-masked image
    RSTask = ENVITask('RasterStatistics')
    RSTask.INPUT_RASTER = ROITask.OUTPUT_RASTER
    RSTask.Execute
   
    ; Construct an array of mean values from the ROIs
    MeanArray = [[MeanArray], [RSTask.MEAN]]
  EndFOR
   
  ; Run SAM classification
  Task = ENVITask('SpectralAngleMapperClassification')
  Task.INPUT_RASTER = CupriteRaster
  Task.MEAN = MeanArray
  Task.OUTPUT_RASTER_URI = e.GetTemporaryFilename()
  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(CupriteRaster)
  roiLayers = !NULL
  FOREACH roi, rois DO $
  roiLayers = [roiLayers, Layer.AddRoi(roi)]
  Layer3 = View.CreateLayer(Task.OUTPUT_RASTER)
END

Version History


ENVI 5.2

Introduced

API Version


3.1.0

See Also


ENVITask, ENVITask::Parameter, ENVISubsetRaster, ENVITrainingClassificationStatisticsTask, ENVIMahalanobisDistanceClassificationTask, ENVIMaximumLikelihoodClassificationTask, ENVIMinimumDistanceClassificationTask



© 2017 Exelis Visual Information Solutions, Inc. |  Legal
My Account    |    Buy    |    Contact Us