Scyllarus: C++ Hyperspectral Processing Library
Hyperspectral Image Processing Pipeline
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
Public Member Functions | Private Attributes | List of all members
scyl::spectral_library Class Reference

Spectral Library is a class that loads and saves SLZ files and holds information from them for use with the Pipeline Object (or independently) More...

#include <spectral_library.h>

Public Member Functions

 spectral_library ()
 
 spectral_library (std::string filename)
 
 spectral_library (arma::fvec wavelengths, std::vector< std::string > labels, arma::fmat endmembers)
 
virtual ~spectral_library ()
 
void load (std::string filename)
 load() initialises the spectral library object that it is called on with the data in the specified file. More...
 
void save (std::string filename)
 save() saves the contents of the spectral_library to the specified SLZ file More...
 
void set_wavelengths (const arma::fvec &in)
 
arma::fvec wavelengths () const
 
void set_metadata (const std::string &in)
 
std::string metadata () const
 
std::vector< std::string > labels (std::string filename="") const
 
std::vector< std::string > loaded_files () const
 
std::vector< std::string > loaded_file_list () const
 
void set_endmembers (const arma::fmat &in_endmembers, const std::vector< std::string > &in_labels)
 
arma::fmat endmembers (std::string label="", std::string filename="") const
 
arma::fmat endmembers_mean () const
 
std::vector< std::string > labels_mean () const
 
void add_endmembers (const arma::fmat &in_endmembers, const std::vector< std::string > &in_labels, std::string filename="")
 Append endmembers onto the list currently held by the object. More...
 
void delete_endmembers (std::string label="", std::string filename="")
 Delete endmembers from the list currently held by the object by label name and or filename. More...
 
void add_library (std::string filename, bool re_evaluate=false)
 Append the contents of a SLZ file to the current contents of the object. More...
 
void add_library (scyl::spectral_library &in, std::string name="nofile", bool re_evaluate=false)
 Append the contents of a spectral_library object to the current contents of the object. More...
 
unsigned int bands ()
 
unsigned int num_endmembers ()
 
void print ()
 

Private Attributes

arma::fvec m_wavelengths
 
std::vector< std::tuple
< std::string, std::string,
arma::fvec > > 
m_endmember_list
 
scyl::iotools::slz m_slz
 
unsigned int m_bands
 
std::string m_metadata
 

Detailed Description

Spectral Library is a class that loads and saves SLZ files and holds information from them for use with the Pipeline Object (or independently)

At the most basic level, the spectral_library can be used as follows:

scyl::spectral_library speclib = scyl::spectral_library("/path/to/file.slz");

To add a spectral_library to the Pipeline:

std::shared_ptr<scyl::spectral_library>  spec_lib  = std::make_shared<scyl::spectral_library>("/path/to/file.slz");
scyl::pipeline pipeline = scyl::pipeline();
pipeline.set_spectral_library(speclib);

Constructor & Destructor Documentation

scyl::spectral_library::spectral_library ( )

Spectral_Library Constructor Creates an empty spectral library object.

scyl::spectral_library::spectral_library ( std::string  filename)

Spectral Library Constructor Creates a spectral library object based on the contents of a loaded file.

Parameters
filenameThe path to the SLZ file to be loaded into this object.
scyl::spectral_library::spectral_library ( arma::fvec  wavelengths,
std::vector< std::string >  labels,
arma::fmat  endmembers 
)

Spectral Library Constructor Creates a spectral library object with contents as given in the constructor arguments.

Parameters
wavelengths- Vector of wavelength values for the given endmembers (bands)
labels- String label descriptions of the endmembers (num_endmembers)
endmembers- Matrix of endmembers, each row is one endmember. (m_bands x num_endmembers)
scyl::spectral_library::~spectral_library ( )
virtual

Spectral Library Destructor

Member Function Documentation

void scyl::spectral_library::add_endmembers ( const arma::fmat &  in_endmembers,
const std::vector< std::string > &  in_labels,
std::string  filename = "" 
)

Append endmembers onto the list currently held by the object.

To add data that has a different number of bands, use add_library() with re_evaluate set to true, or use scyl::spectral_library::resample_endmembers on the data first to make it the correct size.

Parameters
in_endmembers- endmembers to add
in_labels- corresponding labels
filename- source tag (eg, the file the data came from or some other identifying category)
void scyl::spectral_library::add_library ( std::string  filename,
bool  re_evaluate = false 
)

Append the contents of a SLZ file to the current contents of the object.

This function can concatenate end members that have a different number of bands onto the object using NURBS interpolation to adjust the number of bands in the input data.

Parameters
filename
re_evaluateset to true to use NURBS to interpolate data of incompatible size.
void scyl::spectral_library::add_library ( scyl::spectral_library in,
std::string  name = "nofile",
bool  re_evaluate = false 
)

Append the contents of a spectral_library object to the current contents of the object.

This function can concatenate end members that have a different number of bands onto the object using NURBS interpolation to adjust the number of bands in the input data.

Parameters
inThe object to be added
nameThe name of the library (for the purpose of recalling where each group of spectra is from)
re_evaluateset to true to use NURBS to interpolate data of incompatible size.
unsigned int scyl::spectral_library::bands ( )

Get bands

Returns
bands
void scyl::spectral_library::delete_endmembers ( std::string  label = "",
std::string  filename = "" 
)

Delete endmembers from the list currently held by the object by label name and or filename.

This function takes a list of labels, and looks them up in the endmember list to find their indexes before calling the uvec version of this function. If a label appears multiple times, all instance will be removed.

Example:

std::vector<std::string> removes;
removes.pushback("label1");
spectral_library.delete_endmembers(removes);
Parameters
label- the label to delete
filename- The filename to delete
arma::fmat scyl::spectral_library::endmembers ( std::string  label = "",
std::string  filename = "" 
) const

Gets endmembers (Get the corresponding labels using labels() with identical arguments)

Optional filters are available to narrow the returned results if desired. The label filter will filter endmembers matching that label (exactly), the filename filter will filter labels loaded from that file (you can use loaded_files() to get the list of filenames) Leaving both as "" will return all endmembers. Leaving label as "" and setting filename will return all endmembers for a specific file. Leaving filename as "" and setting label will return only endmembers that match that label.

Parameters
label- String filter for desired label
filename- String filter for desired filename
Returns
List of matching endmembers (each row is one endmember)
arma::fmat scyl::spectral_library::endmembers_mean ( ) const

Gets mean endmembers (use label_mean() to get corresponding labels)

If there are multiple identical labels in the library, this function will reduce then to a set of unique label endmembers (if multiple identical labels are found their endmembers are averaged)

Returns
List of unique averaged endmembers (each row is one endmember)
std::vector< std::string > scyl::spectral_library::labels ( std::string  filename = "") const

Gets labels

if the filename argument is set to "" (default) then all labels are returned, otherwise only labels that are associated (were loaded from) the given filename are returned. You can get the list of loaded files using loaded_files().

Parameters
filenameAn optional filter of the filename the labels were loaded from
Returns
A vector of the string names for each endmember.
std::vector< std::string > scyl::spectral_library::labels_mean ( ) const

Gets mean endmember labels (use endmember_mean() to get corresponding endmembers)

If there are multiple identical labels in the library, this function will reduce then to a set of unique labels.

Returns
List of unique labels
void scyl::spectral_library::load ( std::string  filename)

load() initialises the spectral library object that it is called on with the data in the specified file.

load() will overwrite the entire contents of the spectral_library object it is called upon. It populates the following member variables:

- wavelengths
- bands
- labels
- endmembers
Parameters
filenameThe path to the SLZ file to be loaded into this object.
std::vector< std::string > scyl::spectral_library::loaded_file_list ( ) const

Gets the list of files corresponding to each endmember.

Returns
A vector of the string representations of filename for each endmember.
std::vector< std::string > scyl::spectral_library::loaded_files ( ) const

Gets the list of files that have been loaded into the spectral_library.

Returns
A vector of the string representations of each file that has been loaded.
std::string scyl::spectral_library::metadata ( ) const

Gets metadata

Returns
metadata
unsigned int scyl::spectral_library::num_endmembers ( )

Get num_endmembers

Returns
num_endmembers
void scyl::spectral_library::print ( )
void scyl::spectral_library::save ( std::string  filename)

save() saves the contents of the spectral_library to the specified SLZ file

Parameters
filenameThe path to the SLZ file to be saved.
void scyl::spectral_library::set_endmembers ( const arma::fmat &  in_endmembers,
const std::vector< std::string > &  in_labels 
)

Sets endmembers (pair of label vector and endmember matrix)

Parameters
in_endmembersendmembers
in_labelsvector of corresponding labels
void scyl::spectral_library::set_metadata ( const std::string &  in)

Sets metadata

Parameters
instring of metadata
void scyl::spectral_library::set_wavelengths ( const arma::fvec &  in)

Sets wavelengths

If the wavelength vector's length doesn't match the number of bands of the currently held elements, the class is flushed before setting the new wavelengths.

Parameters
inVector of wavelengths
arma::fvec scyl::spectral_library::wavelengths ( ) const

Gets wavelengths

Returns
wavelengths

Member Data Documentation

unsigned int scyl::spectral_library::m_bands
private
std::vector<std::tuple<std::string, std::string, arma::fvec> > scyl::spectral_library::m_endmember_list
private
std::string scyl::spectral_library::m_metadata
private
scyl::iotools::slz scyl::spectral_library::m_slz
private
arma::fvec scyl::spectral_library::m_wavelengths
private

The documentation for this class was generated from the following files: