Skip to main content

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:

  1. Shape of train and test arrays are (DimX, DimY, SpectralChannels).
  2. Shape of label and prediction arrays are (DimX, DimY).
  3. Labeling convention for classifiers: (a) Datatype: label.dtype == np.uint8. (b) Labeled classes start from integer 1. Pixels with label == 0 are ignored (masked out).
  4. Dimension(s) of train and label must be consistent: train.shape[0] == label.shape[0] and train.shape[1] == label.shape[1].
  5. Inputs: train, test, and label can also be lists of np.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

Acknowledgement

Some functionalities in this package are provided by Spectral Python (SPy): https://github.com/spectralpython/spectral

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hskl-0.0.1.1.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hskl-0.0.1.1-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file hskl-0.0.1.1.tar.gz.

File metadata

  • Download URL: hskl-0.0.1.1.tar.gz
  • Upload date:
  • Size: 6.2 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

Hashes for hskl-0.0.1.1.tar.gz
Algorithm Hash digest
SHA256 53f7a627f1b494467af0598bddd446076fb7ddbd66b685374afce7f3e604265e
MD5 8069f8d3165f7781d9b3075457cb6662
BLAKE2b-256 144ed5830eb77390ff9653f7824a8eb3ca3ab2bf34b6b698436fa0507c186be9

See more details on using hashes here.

File details

Details for the file hskl-0.0.1.1-py3-none-any.whl.

File metadata

  • Download URL: hskl-0.0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.2 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

Hashes for hskl-0.0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b497d1a9feba94e6560e8362479cf71f1483dd86fc1f356b41383744cb6964d6
MD5 3a8016190b85a3238d90e7881d1d9317
BLAKE2b-256 b9c2109fe7716467634d91efcb055ac794d3ef18e9a0faa5ea5443231328d2dc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page