Skip to content

corinef/Automated-root-classification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Automated-root-classification

Description

This code is for classifying hyperspectral images that were generated using the IMEC VNIR SNAPSCAN camera. The code may be used for other hyperspectral datasets, however to use the data from Spectral Angle Mapper supervised classification, the images will need to be processed in other software if HSI Studio from IMEC is not available. The code is split into four separate scripts, which need to be run one after the other, to save computer memory when using larger number of sample data.

This code will generate the results under a new folder 'Data_classification_results'. These will contains:
(1) The K-Means classified data as a classified image and the labelled pixel matrix
(2) The data pre-treatments comparing the selection spectra, selected bands, and the selected wavelengths plotted over the second derivative of the root spectra
(3) The generation of the classification model, with the model training confusion matrix, and classification report
(4) The model predicted images, labelled pixel matrices, confusion matrics, accuracy reports, comparison of the predicted spectra, and PLS-DA plots, and estimated biomass

Files needed

Two images in Data_files are provided as an example of how the code works. The raw image data is in ENVI format, containing a header file (.hdr) and raw data file (.raw). Both are needed to extract the raw data. The classified image data from SAM in HSI Studio (IMEC) contains the class image (.png) and the spectra for each class (.csv).

Protocol of running code.

How to install

Prerequisites

Dependencies needed

pip install -r https://github.com/corinef/Automated-root-classification/blob/main/requirements.txt

Step-by-step guide for processing images

K-Means clustering

  • Load data files
  • Run K-Means
  • Save classified images and spectral output

Spectral data pre-treatment

  • Load spectral output from SAM and K-Means
  • Plot original spectra
  • Run SG smoothing
  • Take the average of all root spectra
  • Find peaks
  • Save selected bands to .csv

Model training

  • Load data files
  • Load classified images
  • Load selected bands
  • Crop datacubes to a 300x300 pixel region and extract the pixel labels from the classification method
  • Convert the datacube and pixel labels to a dataframe and reduce the bands (columns) to the selected bands
  • Merge all datasets to one dataframe
  • Run the classification model on the dataframe

Model prediction

Example of image interpretation.


Results of SAM (left) and K-Means (right) classification


Comparison of classification method spectra

Selected_wavelengths_SAM_rootspectra Selected_wavelengths_kmans_rootspectra

Selected wavelengths from the second derivative of the root spectra


Cropped region of datacube (left), SAM classified image (middle), K-Means classified image (right)

Random Forest (RF) model confusion matrix, SAM (left), K-Means (right)

RF predicted image from SAM (left), K-Means (right)

Accuracy_reports

Accuracy reports

Predicted_spectra

Comparison of predicted spectra

Biomass

Estimated biomass

Libraries used

License

  • This project is licensed under the Apache 2.0 License.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published