Welcome to Spectral Python (SPy)¶
Spectral Python (SPy) is a pure Python module for processing hyperspectral image data. It has functions for reading, displaying, manipulating, and classifying hyperspectral imagery. It can be used interactively from the Python command prompt or via Python scripts. SPy is free, Open Source software distributed under the MIT License. To see some examples of how SPy can be used, you may want to jump straight to the documentation sections on Displaying Data or Spectral Algorithms. A categorized listing of the main classes and functions are in the Class/Function Glossary. You can download SPy from GitHub or the Python Package Index (PyPI). See the Installing SPy section section of the documentation for details.
Documentation¶
News¶
2020-04-26 : As of version 0.21, Spectal Python (SPy) is released under the MIT License.
2019-10-06 : SPy 0.20 adds support for the ECOSTRESS spectral library.
2017-06-04 : SPy 0.19 provides plotting support for bad band lists and adds a few utility methods.
2016-06-18 : SPy 0.18 fixes several bugs and has improved ENVI header support.
2015-11-11 : SPy 0.17 enables mapping class labels between images.
Class labels can be mapped between images (e.g., from an unsupervised classification result to a ground truth image) using
map_class_ids
andmap_classes
. ENVI file handling is improved,view_nd
image windows support arbitrary axis labels, andSpyFile
objects have improved numpy ndarray interfaces. See the SPy 0.17 release notes for details. And thanks to Don March for many contributions to this release.
2014-10-18 : SPy 0.16.0 provides initial support for Python 3.
This release supports Python 3 for all functions except
view_cube
andview_nd
. Note that for Python 3, you should use the Qt4Agg matplotlib backend.New features in this release include the Adaptive Coherence/Cosine Esimator (
ace
) target detector, Pixel Purity Index (ppi
), ability to save ENVI classification files (envi.save_classification
), and linear contrast enhancement (by data limits or cumulative histogram percentiles). The SPyimshow
function now applies a 2% histogram color stretch by default (this can be overridden in thespectral.settings
object).Additional info is in the version 0.16.0 issues.
2014-06-04 : SPy 0.15.0 is released.
This version adds the Minimum Noise Fraction algorithm (
mnf
) (a.k.a., Noise-Adjusted Principal Components). The related functionnoise_from_diffs
performs estimation of image noise from a spectrally homogeneous region of the image.
SpyFile
read methods now accept an optional use_memmap argument that provides finer control over when to use (or not use) the memmap interface to read image file data.Many thanks to Don March (http://ohspite.net) for improving ENVI header support (comment lines and blank parameters are now accepted) and providing several performance improvements.
Additional details are here.
2014-03-02 : SPy has moved!
The Spectral Python web site is now located at www.spectralpython.net. All old URLs will automatically redirect to the new site. The primary source code repository has also moved and is now hosted on GitHub at https://github.com/spectralpython/spectral. For the indefinite future, source code and release builds will continue to be mirrored on Sourceforge.net and as always, the current release can always be installed from the Python Package Index (PyPI) using pip.
2014-02-23 : SPy 0.14 is released. This is primarily a bug fix release.
This release fixes a bug in
PerceptronClassifier
and provides significant performance improvement. A bug is also fixed that causes incorrect display of several faces in theview_cube
image cube display. See VERSIONS.txt file for full details.
2014-01-06 : Numerous new user interface features and performance improvements in SPy 0.13.
The SPy
imshow
wrapper around matplotlib’simshow
function provides numerous new features, including:
Interactive image class labeling using keyboard & mouse
Zoom windows
Class overlays with adjustable transparency
Dynamic view of changing pixel classes when modified in an ND Window.
Data/Statistic cacheing and more efficient use of numpy provides significant performance improvement in mutiple algorithms (GMLC 14x, Mahalanobis classifier 8x, kmeans 3x). Functions
rx
andmatched_filter
are significantly faster, particularly when using common global covariance.The
cov_avg
function computes covariance averaged over a set of classes (useful when samples are limited or global covariance is desired). Christian Mielke provided code for themsam
function, which computes the Modified SAM score (by Oshigami et al).
2013-09-06 : SPy 0.12 is released.
SPy 0.12 provides an improved memmap interface that enables accessing image data using arbitrary interleaves and supports editable images (see
open_memmap
for details). The RX anomaly detector (rx
) now allows anomaly detection using local (sub-image) statistics by specifying an inner/outer window around each pixel. The ability to disable algorithm progress messages and addition of a wrapper around matplotlib’s imshow function are provided to simplify integration of SPy code with IPython Notebooks.
2013-04-03 : SPy 0.11 is released.
This release adds an
RX
anomaly detector, ability to save and create images in ENVI format (seesave_image
andcreate_image
), and a unit-testing sub-package. The top-level namespace has been simplified and several functions have been renamed for consistency (image
is nowopen_image
andsave_image
is nowsave_rgb
).
2013-02-23 : SPy 0.10.1 bug-fix release is now available.
This is a bug-fix release that corrects the spectrum displayed when double- clicking on a raster display. Version 0.10 introduced a bug that had the row/column swapped, resulting in either the wrong pixel being plotted or an exception raised.
If you have installed SPy 0.10, you should install this update as soon as possible.
2013-02-17 : SPy 0.10 is released: SPy now uses IPython for GUI display.
As of this release, SPy now uses IPython for non-blocking GUI windows. IPython should be started in pylab mode with the appropriate backend set (see Starting IPython). The standard python interpreter can still be used if GUI functions are not being called. This release also resolves a number of issues associated with different versions of wxWidgets (2.8.x vs. 2.9.x) on various operating systems.
2013-01-23 : SPy 0.9 adds a linear matched filter target detector.
MatchedFilter
uses background and target means, along with background covariance to provide a linear target detector.A generic
LinearTransform
class allows simple application of linear transforms to numpy ndarrays orSpyFile
objects.
2012-07-10 : SPy 0.8 adds N-Dimensional visualization of hyperspectral image data.
The
ndwindow
function enables viewing of high-dimensional images in a 3D display. See N-Dimensional Feature Display for details.Hypercube display now uses mouse control for pan/zoom/rotate.
Fixed a bug in several deprecation warnings that caused infinte recursion.
2012-02-19 : SPy 0.7 Released.
The
kmeans
algorithm is about 10 times faster than version 0.6. Many method/function names have been renamed for consistency with external packages. A few bugs potentially affecting BIP and BSQ input have been fixed.
2011-01-17 : SPy 0.6 Released.
This release adds ASTER Spectral Library support, ability to save spectral libraries, and installation via
distutils
.