LinearSpectralUnmixing Task

This task performs Linear Spectral Unmixing, which determines the relative abundance of materials that are depicted in multispectral or hyperspectral imagery based on the endmembers’ spectral signatures. See Linear Spectral Unmixing for details.

Example

This example performs Linear Spectral Unmixing on an AVIRIS hyperspectral image, using mineral endmembers from a spectral library. The resulting image contains six bands. The first five bands are abundance images for each spectral endmember. The sixth band is an RSM error image. The pixel values of the abundance images indicate the fraction of the pixel that contains the corresponding endmember material.

PRO ENVILinearSpectralUnmixingTaskExample

COMPILE_OPT IDL2

 

; Start the application

e = ENVI()

 

; Open an input file

File = Filepath('cup95eff.int', Subdir=['classic', 'data'], $

  Root_Dir=e.Root_Dir)

Raster = e.OpenRaster(File)

 

; Open a spectral library

SpecLibFile = Filepath('minerals_beckman_3375.sli', $

  Subdir=['resource', 'speclib', 'usgs'], $

  Root_Dir=e.Root_Dir)

SpecLib = ENVISpectralLibrary(SpecLibFile)

Metadata = Raster.Metadata

nBands = Raster.NBands

 

; Apply reflectance scale factor if applicable

IF (Metadata.Tags.HasValue('REFLECTANCE SCALE FACTOR')) THEN BEGIN

  scaleFactor = Metadata['REFLECTANCE SCALE FACTOR']

  GainOffsetTask = ENVITask('ApplyGainOffset')

  gains = Make_Array(nBands, VALUE=1D/scaleFactor, /DOUBLE)

  offsets = Make_Array(nBands, VALUE=0D, /DOUBLE)

  GainOffsetTask.INPUT_RASTER = raster

  GainOffsetTask.GAIN = gains

  GainOffsetTask.OFFSET = offsets

  GainOffsetTask.Execute

  Raster = GainOffsetTask.OUTPUT_RASTER

ENDIF

 

; Specify the endmember names

endmemberNames = ['Alunite GDS84 Na03 [W1R1Ba AREF]', $

  'Kaolinite CM9 [W1R1Bb AREF]', $

  'Calcite CO2004 [W1R1Bb AREF]', $

  'Buddingtonite GDS85 D-206 [W1R1Bb AREF]', $

  'Muscovite GDS107 [W1R1Ba AREF]']

nEndmembers = N_Elements(endmemberNames)

endmembers = DblArr(Raster.NBands, nEndmembers, /NOZERO)

 

; Get endmembers from the spetral library

; and resample them to match the input raster

FOR i=0, nEndmembers-1 DO BEGIN

  SpecTask = ENVITask('GetSpectrumFromLibrary')

  SpecTask.INPUT_SPECTRAL_LIBRARY = SpecLib

  SpecTask.SPECTRUM_NAME = endmemberNames[i]

  SpecTask.Execute

 

  ResampleTask = ENVITask('ResampleSpectrum')

  ResampleTask.INPUT_SPECTRUM = SpecTask.SPECTRUM

  ResampleTask.INPUT_WAVELENGTHS = SpecTask.WAVELENGTHS

  ResampleTask.INPUT_WAVELENGTH_UNITS = SpecTask.WAVELENGTH_UNITS

  ResampleTask.RESAMPLE_WAVELENGTHS = Metadata['WAVELENGTH']

  ResampleTask.RESAMPLE_WAVELENGTH_UNITS = Metadata['WAVELENGTH UNITS']

  ResampleTask.Execute

 

  endmembers[0, i] = ResampleTask.OUTPUT_SPECTRUM

ENDFOR

 

; Get the Linear Spectral Unmixing task

Task = ENVITask('LinearSpectralUnmixing')

 

; Define inputs

Task.INPUT_RASTER = Raster

Task.ENDMEMBERS = endmembers

Task.NAMES = endmemberNames

Task.WEIGHT = 0.0

 

; Run the task

Task.Execute

 

; Get the data collection

DataColl = e.Data

 

; Add the output to the data collection

DataColl.Add, Task.OUTPUT_RASTER

 

; Display the result

View = e.GetView()

Layer = View.CreateLayer(Task.OUTPUT_RASTER)

 

END

See More Examples below.

Syntax

Result = ENVITask('LinearSpectralUnmixing')

Input parameters (Set, Get): ENDMEMBERS, INPUT_RASTER, NAMES, OUTPUT_RASTER_URI, WEIGHT

Output parameters (Get only): OUTPUT_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

ENDMEMBERS (required)

Specify a floating-point array with the spectral endmembers. The array size is [number of bands, number of endmembers]. You can select endmember spectra from different sources such as ASCII spectra, spectral libraries, spectral plots, statistics files, and regions of interest (ROIs).

INPUT_RASTER (required)

Specify a raster on which to perform Linear Spectral Unmixing.

NAMES (required)

Specify an array of endmember names. The array size must be [number of endmembers].

OUTPUT_RASTER_URI (optional)

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

WEIGHT (optional)

Specify a weight when applying a unit sum constraint. Larger weights cause the unmixing to honor the unit-sum constraint more closely. The default value is 1.0.

Output Parameters

OUTPUT_RASTER

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

The output raster consists of bands that represent the relative abundance of features (0 to 1, one for each input endmember), plus an additional band of RMS Error values.

Methods

Execute

Parameter

ParameterNames

Properties

DESCRIPTION

DISPLAY_NAME

NAME

REVISION

TAGS

More Examples

This example performs Linear Spectral Unmixing on an AVIRIS hyperspectral image, using an ASCII file of spectral endmembers.

The example uses sample images that are available from our ENVI Tutorials web page. Click the Hyperspectral link to download the .zip file to your machine, then unzip the files. Update the file references in the example with the correct locations.

; Start the application

e = ENVI()

 

; Open an input file

File = 'mof94av.bil'

Raster = e.OpenRaster(File)

 

; Read endmember from an ASCII file

EndmemberFile = 'm94_em.asc'

Data = Read_ASCII(EndmemberFile, DATA_START=21) ; Skip the header

Endmember = Transpose(Data.Field01[1:*,*]) ; Skip the wavelength column

 

; Get the task from the catalog of ENVITasks

Task = ENVITask('LinearSpectralUnmixing')

 

; Define inputs

Task.INPUT_RASTER = Raster

Task.ENDMEMBERS = Endmember

 

; Define outputs

Task.OUTPUT_RASTER_URI = e.GetTemporaryFilename()

 

; Run the task

Task.Execute

 

; Get the data collection

DataColl = e.Data

 

; Add the output to the data collection

DataColl.Add, Task.Output_Raster

 

; Display the result

View1 = e.GetView()

Layer1 = View1.CreateLayer(Task.Output_Raster)

Version History

ENVI 5.4.1

Introduced

ENVI 6.0

Added the NAMES parameter

See Also

ENVITask, Masking Support in ENVITasks