### Navigation

- index
- modules |
- PySptools 0.12.1 beta documentation »

# 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

### Navigation

- index
- modules |
- PySptools 0.12.1 beta documentation »