Hyperspectral image analysis with scikit-learn.
Project description
HSKL: Hyperspectral-scikit-learn
Hyperspectral image analysis using scikit-learn
Installation
The package can be installed from pip:
pip install hskl
Usage
Training a pixel-level classifier for segmentation:
import hskl.classification as classification
import hskl.utils as utils
# List method names
methods = classification.list_methods()
# Load training, testing, and label images (numpy.ndarray)
train, test, label = ...
# Dimensional reduction using PCA, retain 80% image variance
pca = utils.pca_fit(train)
train = utils.pca_apply(train, pca, 0.8)
test = utils.pca_apply(test, pca, 0.8)
# Train a classifier and predict test image labels
cl = classification.HyperspectralClassifier(
method_name=”RandomForest”,
method_params={"max_depth": 2})
cl.fit(train, label)
prediction = cl.predict(test)
# Visualization of classification result overlaid with original image
fig_objs = utils.overlay(test,prediction)
Notes:
- Shape of
trainandtestarrays are (DimX, DimY, SpectralChannels). - Shape of
labelandpredictionarrays are (DimX, DimY). - Labeling convention for classifiers:
(a) Datatype:
label.dtype == np.uint8. (b) Labeled classes start from integer 1. Pixels withlabel == 0are ignored (masked out). - Dimension(s) of
trainandlabelmust be consistent:train.shape[0] == label.shape[0]andtrain.shape[1] == label.shape[1]. - Inputs:
train,test, andlabelcan also be lists ofnp.ndarrays with each element satisfying the preceeding requirements.
Planned Features
In the near-term:
- Test scripts and data
- Grid search cross validation
In the long-term, support for:
- Pipelines
- Patch-based featurizer
- Dask-enabled parallelism
- Deep learning (PyTorch) models
Acknowledgement
Some functionalities in this package are provided by Spectral Python (SPy): https://github.com/spectralpython/spectral
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hskl-0.0.2.dev1.tar.gz.
File metadata
- Download URL: hskl-0.0.2.dev1.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.1.post20201107 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.7.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
24bcd27e20c2503626bc4f1a9000b6b93d2b0b18c9285a4b8aa4c627e1032a83
|
|
| MD5 |
06e484cf25aea3e8326c42e0768d9315
|
|
| BLAKE2b-256 |
cb89b9e3aaf92128b4ec92f355a1393399c7b44bec9c248f1b8c8c92f6fdf248
|
File details
Details for the file hskl-0.0.2.dev1-py3-none-any.whl.
File metadata
- Download URL: hskl-0.0.2.dev1-py3-none-any.whl
- Upload date:
- Size: 10.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.1.post20201107 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.7.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b153132f39033fe4ba2c67cf427d25f375d8b907a8320cae3c8f3bca82348505
|
|
| MD5 |
adc43615d7943f1a999f3374fb99470d
|
|
| BLAKE2b-256 |
e79153d3c2dc61850ee14cd51563861e17b5129e891174635c86d2788ee8db8e
|