Classifies an image using a spectral measure.


This application computes a spectral measure on a hyperspectral data cube using a set of reference pixels. The image is then classified by finding for each pixel the index of its closest endmember, i.e. the endmember corresponding to the lowest measurement value. The output classification is labeled from 1 to L, L being the number of endmembers. A threshold can be set for the classification step, only measurement values lower than this threshold will be considered, other will be classified as background values (default value of 0).

Two measures are available : the spectral angle mapper and the spectral information divergence. See [1] for details

This application has several output images and supports “multi-writing”. Instead of computing and writing each image independently, the streamed image blocks are written in a synchronous way for each output. The output images will be computed strip by strip, using the available RAM to compute the strip size, and a user defined streaming mode can be specified using the streaming extended filenames (type, mode and value). Note that multi-writing can be disabled using the multi-write extended filename option: &multiwrite=false, in this case the output images will be written one by one. Note that multi-writing is not supported for MPI writers.


Input Image Filename -in image Mandatory
The hyperspectral data cube input

Input endmembers -ie image Mandatory
The endmembers (estimated pure pixels) to use for unmixing. Must be stored as a multispectral image, where each pixel is interpreted as an endmember.

Output spectral angle values -measure image [dtype]
Output image containing for each pixel from the input image the computed measure relative to each endmember

Output classified image -out image [dtype]
Output classified image, classified pixels are labeled from 1 to L, L being the number of endmember in the image.

Measure used for classification -mode [sam|sid] Default value: sam
Measure used for classification

  • Spectral angle mapper
    Spectral angle mapper (SAM) measure.

  • Spectral information divergence
    Spectral information divergence (SID) measure. Input pixel values should be strictly positive.

Classification threshold -threshold float
Pixel with a measurement greater than this threshold relatively to a reference pixel are not classified. The same threshold is used for all classes.

Background value -bv int Default value: 0
Value of unclassified pixels in the classification image (this parameter is only used if a threshold is set).

Available RAM (MB) -ram int Default value: 256
Available memory for processing (in MB).


From the command-line:

otbcli_SpectralAngleClassification -in cupriteSubHsi.tif -ie cupriteEndmembers.tif -out classification.tif -measure measure.tif -mode sam -threshold 0.1

From Python:

import otbApplication

app = otbApplication.Registry.CreateApplication("SpectralAngleClassification")

app.SetParameterString("in", "cupriteSubHsi.tif")
app.SetParameterString("ie", "cupriteEndmembers.tif")
app.SetParameterString("out", "classification.tif")
app.SetParameterString("measure", "measure.tif")
app.SetParameterFloat("threshold", 0.1)



In sid mode, the pixels of the input image and the input endmembers should be strictly positive. The endmember image is fully loaded in memory.

See also

[1] Du, Yingzi & Chang, Chein-I & Ren, Hsuan & Chang, Chein-Chi & Jensen, James & D’Amico, Francis. (2004). New Hyperspectral Discrimination Measure for Spectral Characterization. Optical Engineering - OPT ENG. 43. 1777-1786. 10.1117/1.1766301.