Page tree
Skip to end of metadata
Go to start of metadata

Find here a collection of Matlab functions and scripts as well as data maybe helpful when working with Hyperspectral data in Matlab. 


Content:

Parent page:

Child pages:



Load Hyperspectral Data

% LoadHSData - Load hyperspectral data into Matlab
%
%   C = LoadHSData
%       displays a dialog box for the user to select a *.mat file.
%       If the selected file contains a valid hyperspectral cube (e.g.
%       exported by the Perception Studio program) the cube C is returned.
%
%           C is a matrix of size SxWxT. S is the number of spatial
%           points (spatial domain 1), W is the number of wavelength points
%           (spectral domain), T is the number of samples along the time
%           domain (e.g. statial domain 2).
%           The value range of C is within 0...2^nBits-1 in case of sensor
%           row data. nBits is the sensor dynamic in bits.
%           In case of a reflectance measurement, the values in C are
%           the reflectance values, where 1 is 100% and 0 is 0%.
%
%   C = LoadHSData( strFilename )
%       same as above expected the file specified by the string strFilename
%       is read.
%
%   [C, p, u] = LoadHSData( strFilename )
%       same as above expected the wavelength calibration polynom p and the
%       unit specifier of the spectral domain u is returned too.
%
%       wavelength = p(1)*w^N + p(2)*w^(N-1) +...+ p(N)*w + p(N+1)
%           w...wavelength position (index).
%           N...order of polynom.
%
%       u = 'nm' in case the unit of the spectral domain is nanometers
%       u = 'um' in case the unit of the spectral domain is micrometers
%       u = 'px' in case the unit of the spectral domain is pixel
%       u = 'undef' in case the unit of the spectral domain is undefined
%
% HISTORY
%   14-10-10 - [Markus Burgstaller] First version
%   14-10-18 - [Markus Burgstaller] example added
%
% EXAMPLES
%   Download an example data set from Perception Park GmbH
%   (www.perception-park.com)
%
%   [C,p,u] = LoadHSData('recycling.mat')
%
%   returns:
%       C = [101x256x121 double]
%       p = [-0.0000   -0.0002    6.3103  968.2110]
%       u = 'nm'
%
%   Plot a spectra from the cube:
%       W = size(C,2);              %number of spectral points
%       w = polyval( p , [1:W] );   %wavelengths per spectral point
%       figure;
%       plot( w , C(40,:,80) );     %plot spectra at spatial position 40
%                                   %and sample position (time domain) 80
%       xlabel( sprintf('spectral domain [%s]',u) )   %append x-axis label
%
%                           (c)2014 Perception Park GmbH, Graz/AUSTRIA


LoadHSData.m

Save Hyperspectral Data

% SaveHSData - Save hyperspectral data
%
%   SaveHSData( C )
%       The hyperspectral cube C is saved as *.mat file (compatible to the
%       Perception Studio program). A dialog is displayed eneabling the user
%       to specifiy the name of the *.mat file to be saved.
%
%           C must be a matrix of size SxWxT. S is the number of spatial
%           points (spatial domain 1), W is the number of wavelength points
%           (spectral domain), T is the number of samples along the time
%           domain (e.g. statial domain 2).
%           The value range of C should be 0...2^nBits-1 in case of sensor
%           row data. nBits is the sensor dynamic in bits.
%           In case of a reflectance measurement, the values in C should
%           compare to the reflectance, where 1 is 100% and 0 is 0%.
%
%   SaveHSData( strFilename , C )
%       same as above expected a file specified by the string strFilename
%       is written.
%
%   SaveHSData( strFilename , C , p , u )
%       same as above expected the wavelength calibration polynom p and the
%       unit specifier of the spectral domain u is saved too.
%
%       wavelength = p(1)*w^N + p(2)*w^(N-1) +...+ p(N)*w + p(N+1)
%           w...wavelength position (index).
%           N...order of polynom.
%
%       u = 'nm' in case the unit of the spectral domain is nanometers
%       u = 'um' in case the unit of the spectral domain is micrometers
%       u = 'px' in case the unit of the spectral domain is pixel
%
% HISTORY
%   14-10-17 - [Markus Burgstaller] First version
%
% EXAMPLES
%   Download an example data set from Perception Park GmbH
%   (www.perception-park.com)
%
%   [C,p,u] = LoadHSData('recycling.mat');
%
%   returns:
%       C = [101x256x121 double]
%       p = [-0.0000   -0.0002    6.3103  968.2110]
%       u = 'nm'
%   
%   SaveHSData(C,p,u);
%
%                           (c)2014 Perception Park GmbH, Graz/AUSTRIA


SaveHSData.m

Load CCI Model

% LoadCCIModel - Load a CCI model to file
%
%   [B,B0,K,D,XMeanCenter,name,autoscale] = LoadCCIModel
%       Load 3 linear models as well as name and scaling parameter
%       from CCI model file. A dialog is displayed enabling the user
%       to specify the name of the *.xml file to be read.
%
%           A linear model is specified by the equation: 
%               y_ = b * x_ + b0
%           Where y_ is the predicted value of the mean centered spectra
%           x_, b is an array of length x and b0 is a scalar. In addition
%           scaling can be applied to the predicted values. When
%           autoscaling is on, the Studio program scales the resulting
%           image (prediction image) according the user's selection in the
%           program regardless of the scaling parameters k and d. In case
%           autoscaling is off, the predictions (y_) are scaled according
%           the following equation:
%               y = k y_ + d
%           In case k=1 and d=0 and autoscaling is off, no scaling is
%           applied to the predictions (therefore: y = b * x_ + b0).
%           Typically for chemometric modelling is mean centering
%           of the spectra. This is done by the following equation:
%               x_ = x - xMeanCenter
%           Where x_ is the "mean centered spectra", x is the input spectra
%           and xMeanCenter is the "mean center spectra".
%
%               B is composed of 3 b-vectors:
%               B = [b_1; b_2; b_3];
%
%               B0 is composed of 3 b0-values:
%               B0 = [b0_1, b0_2, b0_3];
%
%               K is composed of 3 k-values:
%               K = [k_1, k_2, k_3];
%
%               D is composed of 3 d-values:
%               D = [d_1, d_2, d_3];
%
%               XMeanCenter is composed of 3 mean-center-spectra:
%               XMeanCenter = [xMeanCenter_1; xMeanCenter_2; xMeanCenter_3];
%
%               name is a string specifying the name of the CCI model.
%
%               autoscale is a boolean variable specifying whether
%               autoscaling should be applied or not (in the Studio program).
%
%   ... = LoadCCIModel( filename )
%       Same as above excepted the model is loaded from the file specified by
%       the string filename.
%
% HISTORY
%   21-10-14 - [Markus Burgstaller] First version
%   23-10-14 - [Markus Burgstaller] Param names updated
%
%
%                           (c)2014 Perception Park GmbH, Graz/AUSTRIA

LoadCCIModel.m

Save CCI Model

% SaveCCIModel - Save a CCI model to file
%
%   C = SaveCCIModel(B,B0,K,D,XMeanCenter,name,autoscale)
%       Save 3 linear models as well as name and scaling parameter
%       as CCI model file. A dialog is displayed enabling the user
%       to specify the name of the *.xml file to be saved.
%
%           A linear model is specified by the equation: 
%               y_ = b * x_ + b0
%           Where y_ is the predicted value of the mean centered spectra
%           x_, b is an array of length x and b0 is a scalar. In addition
%           scaling can be applied to the predicted values. When
%           autoscaling is on, the Studio program scales the resulting
%           image (prediction image) according the user's selection in the
%           program regardless of the scaling parameters k and d. In case
%           autoscaling is off, the predictions (y_) are scaled according
%           the following equation:
%               y = k y_ + d
%           In case k=1 and d=0 and autoscaling is off, no scaling is
%           applied to the predictions (therefore: y = b * x_ + b0).
%           Typically for chemometric modelling is mean centering
%           of the spectra. This is done by the following equation:
%               x_ = x - xMeanCenter
%           Where x_ is the "mean centered spectra", x is the input spectra
%           and xMeanCenter is the "mean center spectra".
%
%               B is composed of 3 b-vectors:
%               B = [b_1; b_2; b_3];
%
%               B0 is composed of 3 b0-values:
%               B0 = [b0_1, b0_2, b0_3];
%
%               K is composed of 3 k-values:
%               K = [k_1, k_2, k_3];
%
%               D is composed of 3 d-values:
%               D = [d_1, d_2, d_3];
%
%               XMeanCenter is composed of 3 mean-center-spectra:
%               XMeanCenter = [xMeanCenter_1; xMeanCenter_2; xMeanCenter_3];
%
%               name is a string specifying the name of the CCI model.
%
%               autoscale is a boolean variable specifying whether
%               autoscaling should be applied or not (in the Studio program).
%
%   C = SaveCCIModel(filename,...)
%       Same as above excepted the model is saved to the file specified by
%       the string filename.
%
% HISTORY
%   21-10-14 - [Markus Burgstaller] First version
%   23-10-14 - [Markus Burgstaller] Param names updated
%   03-03-15 - [Markus Burgstaller] Now output is a xml-file of ending fltp
%
%                           (c)2015 Perception Park GmbH, Graz/AUSTRIA

SaveCCIModel.m

Load Spectra Set

% LoadSpectraSet - Load spectra sets from file
%
%   svSpectraSet = LoadSpectraSet
%       Loads spectra read from a *.sst file and retuns the
%       spectra in a structure variable svSpecSet and coordinate mappings
%       in the structure variable svCoordMap.
%       In case of multiple spectra sets are read, length of svSpecSet > 1.
%       Access the i-th spectra set loaded from file by:
%           svSpecSet(i).I ... all spectra which belongs to spectra set i
%           svSpecSet(i).name ... the name of spectra set i.
%       In case of multiple coordinate mappings are read, length of
%       svCoordMap > 1.
%       Access the j-th coordinate mapping loaded from file by:
%           svCoordMap(j).name ... the name of the coordinate mapping
%           svCoordMap(j).W ... the wavelengths
%           svCoordMap(j).unit ... a string specifing the unit of wavelengths.
%
%       A dialog is displayed enabling the user
%       to specify the name of the *.sst file to be read.
%
%
%   ... = LoadSpectraSet( filename )
%       Same as above excepted the spectra sets are loaded from file
%       specified by the string filename.
%
%
% HISTORY
%   02-03-15 - [Markus Burgstaller] First version
%
%
%                           (c)2015 Perception Park GmbH, Graz/AUSTRIA

LoadSpectraSet.m

Example Data

recycling.mat

 


© 2016 by Perception Park GmbH
The content of this page and any attached files are confidential and intended solely for the addressee(s). Any publication, transmission or other use of the information by a person or entity other than the intended addressee is prohibited. If you receive this in error please contact Perception Park and delete copied material. Perception Park GmbH, Wartingergasse 42, 8010 Graz; Austria; FN 400381x

  • No labels