| Environments | PYTHON :: EASI :: MODELER |
| Quick links | Description :: Parameters :: Parameter descriptions :: Details :: Examples :: Algorithm :: Acknowledgements :: References :: Related |
| Back to top |
Classifies hyperspectral image data, on the basis of a set of reference spectra that define the classes.
The program processes vector-quantized image data generated by the Hierarchical Self- Organizing Cluster Vector Quantization algorithm. Vector-quantized images are processed from 50 to 150 times faster than the corresponding non-vector-quantized images.
The SAM algorithm requires that the image data differ from the physical units of the reference spectra by at most a gain factor that is uniform over all bands. In particular, this means that if the image data are "raw" DN values or represent at- sensor radiance (and therefore exhibit wavelength-specific atmospheric effects) and the reference spectra represent material reflectance then the user should not expect SAM to produce good results.
The image file must contain band response profile metadata.
| Back to top |
sam(fili, dbiw, dbib, specfile, dboc, dbclass, samthres, angscale, rtlevel, dbic, wlenint, valonly)
| Name | Type | Caption | Length | Value range |
|---|---|---|---|---|
| FILI * | str | Input file name | 1 - | |
| DBIW | List[int] | Raster input window | 0 - 4 | Xoffset, Yoffset, Xsize, Ysize |
| DBIB | List[int] | Input bitmap segment | 0 - 1 | 1 - |
| SPECFILE * | str | Spectrum library file name | 1 - | |
| DBOC | List[int] | Output raster channel(s) | 0 - | |
| DBCLASS * | List[int] | Output classification channel | 1 - 1 | 1 - |
| SAMTHRES | List[float] | Spectral angle threshold (deg) | 0 - 1 | 0 - 180 |
| ANGSCALE | List[float] | Output angle scaling factor | 0 - 1 | Default: 1.0 |
| RTLEVEL | List[int] | Radiometric transformation level | 0 - 1 | 0 - |
| DBIC | List[int] | Input raster channel(s) | 0 - | |
| WLENINT | List[float] | Wavelength interval | 0 - 2 | |
| VALONLY | str | Valid bands only | 0 - 3 | YES | NO Default: NO |
| Back to top |
FILI
Specifies the name of the file that contains the image data set to be classified.
DBIW
Optionally specifies the rectangular window (Xoffset, Yoffset, Xsize, Ysize) of image data read from the input channels. If this parameter is not specified, the entire image is processed by default.
Xoffset, Yoffset define the upper-left starting pixel coordinates of the window. Xsize is the number of pixels that define the window width. Ysize is the number of lines that define the window height.
Either DBIW (input window) or DBIB (input bitmap) may be specified.
DBIB
Specifies a bitmap segment that describes an image region to which the processing will be restricted.
Either DBIW (input window) or DBIB (input bitmap) may be specified.
SPECFILE
Specifies the name of the input spectra library file.
DBOC
Specifies the output channel(s) to which the spectral angles for each class will be written. If this parameter is specified, there must be one output channel for each input reference spectrum. The i'th spectrum in the input spectra library file corresponds to the i'th channel in the specified channel list.
Spectral angles are 32-bit real values between 0 and 180. If output channels are not 32r, spectral angles are truncated to integer values.
Duplicate channels are not allowed. No data set band channels can be selected.
DBCLASS
Specifies the output channel to receive the classification results. The datatype of the output channel must cover the number of spectral records present in the spectral library or clipping of the output results will occur. In most cases, 8-bit unsigned channel are sufficient; however, for larger spectral libraries, a 16-bit unsigned channel may be required.
No data set band channels can be selected.
SAMTHRES
Optionally specifies the spectral angle threshold, in degrees (between 0 and 180). If, for a given pixel, the spectral angles for all classes are greater than SAMTHRES, that pixel is assigned to the NULL class (value 0).
ANGSCALE
Optionally specifies a scaling factor to apply to the spectral angle values before saving them in the output channels. This is especially useful when the spectral angles are written to 8-bit channels rather than 32-bit real channels.
For example, to change the output range to 0 - 255, set ANGSCALE to 255/180.
A negative value should not be specified for ANGSCALE when output channels are unsigned 8-bit or 32-bit. ANGSCALE must not be zero.
RTLEVEL
Specifies the radiometric transformations associated with the data set that is applied to the stored pixel values.
RTLEVEL cannot be greater than the number of radiometric transformations available for the selected data set. If this parameter is not specified, it defaults to the number of radiometric transformations present for the selected data set.
DBIC
Specifies the input channels on which to perform the classification.
Only data set band channels may be selected.
WLENINT
Specifies that the selected bands are to be restricted to those whose center wavelength is either inside or outside a closed interval, specified in nanometers. By default, no restriction is applied.
This parameter has no effect if the input file contains no band center wavelength metadata.
VALONLY
Specifies whether the selected bands are to be restricted to those with "plot" or "bmask" (begin mask) quality values. The default is NO.
This parameter has no effect if the input file contains no band-validity metadata.
| Back to top |
The Spectral Angle Mapper (SAM) is designed to classify hyperspectral image data, on the basis of a set of reference spectra that define the classes. SAM computes the "spectral angle" between each band vector in a specified region (DBIW) of the input image (FILI) and each of the spectra read from the input spectra file (SPECFILE). The spectral are treated as band vectors for the purpose of the angle computation. A classification channel (DBCLASS) indicates, for each image pixel, the input reference spectrum with which it has the smallest angle (the minimum spectral angle). Pixels are assigned to the NULL (0) class if the minimum spectral angle is greater than the specified threshold value (SAMTHRES).
If desired, the spectral angles for each class can be saved to a set of output image channels (DBOC). The spectral angle is a 32-bit real value between 0 and 180. Each spectral angle can be multiplied by a real scaling factor (ANGSCALE) before being saved. This is useful when saving spectral angle values on 8-bit channels, to make use of the full range of values (between 0 and 255).
Only image pixels under the bitmap (DBIB) or the input image window (DBIW) are classified.
If necessary, the input reference spectra are automatically resampled to match the image wavelength sampling.
The SAM results are unaffected by the relative scaling of the image band vectors and the reference spectra. This is because the angle between two vectors depends only on the directions of the vectors and not on their magnitudes. Therefore, if the image data differs from the physical units of the reference spectra by only a "gain" factor that is uniform over all bands, the SAM results will be exactly the same as if the image data were perfectly calibrated to the reference spectra units. Note that this is generally not the case if the reference spectra represent material reflectance and the image data are "raw" DN values or represent at-sensor radiance. In such cases, the image values will contain atmospheric absorption features that require at least band-specific (non-uniform) gain values for removal.
A tabular summary of the classification results is printed to the REPORT device.
| Back to top |
Perform a mineral classification of a reflectance data set derived from an AVIRIS hyperspectral image, and a set of laboratory-measured mineral reflectance spectra.
Using the Focus Spectra Plotting panel, extract the reference spectra from splib04b.spl and write them in SPCB (USGS binary) format to file ref04b.spl. The spectra of interest are:
file record description
number
----------- -----------
27 Alunite GDS83 Na63
28 Alunite GDS82 Na82
135 Dickite NMNH106242
185 Halloysite NMNH106237
241 Kaolinite CM9
243 Kaolinite KGa-2 (pxyl)
296 Montmorillonite SWy-1
297 Montmorillonite SAz-1
Using PCIMOD, add channels to the reflectance data (stored in cupref.pix) that will hold the between-spectra angles (eight 32R channels) and the classification results (one 8U channel):
from pci.pcimod import pcimod file = "cupref" pciop = "ADD" pcival = [1,0,0,8] pcimod( file, pciop, pcival)
Using SAM, perform the classification. Constrain the classification to involve only the wavelength range that contains absorption features for the reference spectra. Plots of the reference spectra show this range to be within 800 to 2500nm.
from pci.sam import sam
fili = "cupref.pix"
dbiw = [] # process entire image
dbib = []
specfile = "ref04b.spl"
dboc = list(range(226, 233 + 1)) # newly added 32R channels
dbclass = [1] # newly added 8U channel
samthres = [5] # based on trial and error
angscale = [] # no scaling
rtlevel = [] # use full r.t. sequence
dbic = [] # no channel restriction
wlenint = [800, 2500] # restrict bands to use
valonly = "yes" # use only bands with "valid" and "bmask" quality
sam( fili, dbiw, dbib, specfile, dboc, dbclass, samthres, angscale, rtlevel, \
dbic, wlenint, valonly )
SAM creates the following output report in sam.txt:
Name Code Channel Pixels Image -------------------------------------------------------------------------------- Alunite GDS83 Na63 =a ABSREF950 (res 1 226 0 0.00 Alunite GDS82 Na82 =a ABSREF950 (res 2 227 897 0.07 Dickite NMNH106242 =a ABSREF950 (res 3 228 0 0.00 Halloysite NMNH106237 =a ABSREF950 (res 4 229 10 0.00 Kaolinite CM9 =b ABSREF950 (res 5 230 1 0.00 Kaolinite KGa-2 (pxyl) =b ABSREF950 (res 6 231 179 0.01 Montmorillonite SWy-1 =b ABSREF950 (res 7 232 57217 4.22 Montmorillonite SAz-1 =b ABSREF950 (res 8 233 5 0.00 NULL (unclassified) 1296175 95.70 -------------------------------------------------------------------------------- Total: 1354484 100.00
| Back to top |
This program is based on an algorithm developed by Dr. J.W. Boardman of the Center for the Study of Earth from Space (CSES), Cooperative Institute for Research in Environmental Studies (CIRES) and the Department of Geological Sciences, University of Colorado, Boulder.
The Spectral Angle Mapper (SAM) algorithm is described in pages 156-157 of the following article:
Kruse, F.A., Lefkoff, A.B., Boardman, J.W., Heidebrecht, K.B., Shapiro, A.T., Barloon, P.J., and Goetz, A.F.H. (1993), "The Spectral Image Processing System (SIPS) - Interactive Visualization and Analysis of Imaging Spectrometer Data", Remote Sensing of Environment, Vol. 44, pp. 145-163.
The algorithm computes the angle between a band-vector from an image and a reference spectrum that is interpreted as a vector. This angle is meant to be interpreted as a measure of "spectral similarity" between the band-vector and the reference spectrum; the smaller the angle, the greater the similarity.
The algorithm assumes that the reference spectrum represents the same wavelength sampling as the image (that is, that the number of measurement values in the reference spectrum equals the number of bands in the image, and that the band center wavelength values match the wavelength coordinates of the reference spectrum measurement values).
The angle between a band vector, B, and a reference spectrum, R, is computed as follows:
B(i) = band-vector values (i = 1 to n) R(i) = reference spectrum values (i = 1 to n) |B| = square root of ( sum of (B(i)*B(i)) ) |R| = square root of ( sum of (R(i)*R(i)) ) angle = arccos ( (Sum of (B(i)*R(i))) / ( |B| * |R| ) )
This measure of similarity is insensitive to gain factors because the angle between two vectors is invariant with respect to the lengths of the vectors. As a result, laboratory-measured material spectra can be directly compared to remotely sensed apparent reflectance spectra (from hyperspectral images), which inherently have an unknown gain factor related to topographic illumination effects.
The angle between each reference spectrum and each band vector is computed. SAM assigns the angles to the output channels (DBOC). Then, each pixel is assigned to the class defined by the reference spectrum with which its band vector has the smallest angle (unless the angle is greater than the threshold value (SAMTHRES), in which case the pixel is assigned the NULL class). The class assigned to each pixel is saved in the output classification channel (DBCLASS).
| Back to top |
PCI Geomatics received financial support from the Canadian Space Agency/L'Agence Spatiale Canadienne through the Earth Observation Application Development Program (EOADP) for the development of this software, under contract 9F028-0-4902/12.
| Back to top |
Boardman, J. W., "Analysis, understanding and visualization of hyperspectral data as convex sets in n-space", SPIE Proceedings, Vol. 2480. pp. 14-22. 1995.
Kruse, F.A., Lefkoff, A.B., Boardman, J.W., Heidebrecht, K.B., Shapiro, A.T., Barloon, P.J., and Goetz, A.F.H. (1993), "The Spectral Image Processing System (SIPS) - Interactive Visualization and Analysis of Imaging Spectrometer Data", Remote Sensing of Environment, Vol. 44, pp. 145-163.
© PCI Geomatics Enterprises, Inc.®, 2026. All rights reserved.