Util functions
The function load_ENVI_file is use by the examples to load HSI cubes
that are saved in the ENVI file format. The functions corr and cov are the one
defined in the Matlab Hyperspectral Toolbox.
load_ENVI_file
-
util.load_ENVI_file(file_name)
Load the data, the wavelength vector and the wavelength units from an ENVI file.
It use the SPy (spectral) library. At ‘file_name’ give the envi header file name.
- Parameters:
- file_name: path string
- The complete path to the file to load. Use the header file name.
- Returns: tuple
- data: numpy array
- A (m x n x p) HSI cube.
- info: dictionary
- info[‘z plot titles’] : a list, first position is the x axis label,
second position is the y axis label.
- info[‘wavelength’] : a wavelengths list (1D python list).
- info[‘wavelength units’] : the x axis units, ‘Unknown’ if not specified.
load_ENVI_spec_lib
-
util.load_ENVI_spec_lib(file_name)
Load a ENVI .sli file.
- Parameters:
- file_name: path string
- The complete path to the library file to load.
- Returns: numpy array
- A (n x p) HSI cube.
corr
-
util.corr(M)
Compute the sample autocorrelation matrix of a 2D matrix.
- Parameters:
- M: numpy array
- 2d matrix of HSI data (N x p)
- Returns: numpy array
- Sample autocorrelation matrix.
cov
-
util.cov(M)
Compute the sample covariance matrix of a 2D matrix.
- Parameters:
- M: numpy array
- 2d matrix of HSI data (N x p)
- Returns: numpy array
- sample covariance matrix
display_linear_stretch
-
util.display_linear_stretch(M, R, G, B, suffix=None)
Display a linear stretched RGB image.
- Parameters:
- M: numpy array
- A HSI cube (m x n x p).
- R: int
- A band number that will render the red color.
- G: int
- A band number that will render the green color.
- B: int
- A band number that will render the blue color.
- suffix: string [default None]
- Add a suffix to the title.
plot_linear_stretch
-
util.plot_linear_stretch(M, path, R, G, B, suffix=None)
Plot a linear stretched RGB image.
- Parameters:
- M: numpy array
- A HSI cube (m x n x p).
- path: string
- The path where to put the plot.
- R: int
- A band number that will render the red color.
- G: int
- A band number that will render the green color.
- B: int
- A band number that will render the blue color.
- suffix: string [default None]
- Add a suffix to the file name.