GetColorSlices Task

This task retrieves data ranges and colors from a density slice range file (.dsr). Density slices are used to group pixel values into discrete ranges, each with a different color. Overlaying a density slice on an associated image is helpful for visualizing image processing results. Density slices can also be used as input into color slice classification.

Example

This example creates a Red Edge NDVI spectral index image from an AVIRIS hyperspectral scene. It creates a density slice, where the healthiest vegetation is colored bright green. It then creates a classification raster from the density slice.

; Start the application

e = ENVI()

 

; Open an AVIRIS hyperspectral image

file = FILEPATH('AVIRISReflectanceSubset.dat', $

  ROOT_DIR=e.ROOT_DIR, $

  SUBDIRECTORY = ['data', 'hyperspectral'])

raster = e.OpenRaster(file)

 

; Compute a Red Edge NDVI spectral index

SITask = ENVITask('SpectralIndex')

SITask.INPUT_RASTER = raster

SITask.INDEX = 'Red Edge Normalized Difference Vegetation Index'

SITask.Execute

 

; Get the collection of data objects currently available in the Data Manager

DataColl = e.Data

DataColl.Add, SITask.OUTPUT_RASTER

 

; Open a density slice range (DSR) file

DSRfile = FILEPATH('RENDVIColorSlice.dsr', $

  ROOT_DIR=e.ROOT_DIR, $

  SUBDIRECTORY = ['data', 'hyperspectral'])

 

; Get the density slice task from the catalog of ENVITasks

Task = ENVITask('GetColorSlices')

 

; Define inputs

Task.INPUT_DSR_URI = DSRfile

 

; Run the task

Task.Execute

 

; Create a classification raster based on the density slice

ClassTask = ENVITask('ColorSliceClassification')

ClassTask.INPUT_RASTER = SITask.OUTPUT_RASTER

ClassTask.CLASS_COLORS = Task.COLORS

ClassTask.CLASS_RANGES = Task.RANGES

ClassTask.Execute

DataColl.Add, ClassTask.OUTPUT_RASTER

 

; Display the result

View = e.GetView()

Layer1 = View.CreateLayer(SITask.OUTPUT_RASTER)

Layer2 = View.CreateLayer(ClassTask.OUTPUT_RASTER)

Syntax

Result = ENVITask('GetColorSlices')

Input properties (Set, Get): INPUT_DSR_URI

Output properties (Get only): COLORS, RANGES

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:

COLORS

An array with the RGB colors for the given ranges.

INPUT_DSR_URI (required)

Specify a string with the fully qualified path and filename for the density slice range file (.dsr).

RANGES

An array of color slice ranges.

Version History

ENVI 5.3

Introduced

API Version

4.2

See Also

ENVITask, ExportColorSlices Task, ColorSliceClassification Task