## Support for Singleton Dimensions

Image Processing Toolbox™ Hyperspectral Imaging Library represents hyperspectral images as three-dimensional (3-D) arrays of the form M-by-N-by-P, where M and N are the spatial dimensions of the acquired data, and P is the number of spectral wavelengths used during acquisition. However, hyperspectral data can also be spectral reflectance curves obtained from ground spectrometers, and are arranged sequentially without a spatial dimension. This spectral response can be stored as a vector or a matrix. A vector of spectral data contains a single spectral reflectance curve, and a matrix of spectral data contains multiple spectral reflectance curves in sequence.

To process spectral data use these functions in Image Processing Toolbox Hyperspectral Imaging Library, that also support hyperspectral images.

 Explore, Analyze, and Visualize Data Correction Dimensionality Reduction Spectral Unmixing Spectral Matching and Target Detection `hypercube` `dn2radiance``dn2reflectance``radiance2Reflectance``empiricalLine``flatField``iarr``logResiduals``subtractDarkPixel` `hyperpca``hypermnf``inverseProjection` `ppi``fippi``nfindr``estimateAbundanceLS` `sam``sid``jmsam``sidsam``ns3``spectralMatch``ndvi``anomalyRX`

To use 1-D or 2-D spectral data for the hyperspectral functions, you must reshape it into 3-D volume data:

• Reshape 1-D spectral data of size 1-by-P into a 3-D hypercube of size 1-by-1-by-P, where P is the spectral dimension. For example,

```spectralDim = size(spectralData1D,2); dataCube = reshape(spectralData1D,[1 1 spectralDim]); hCube = hypercube(dataCube,wavelength);```

reshapes the 1-D spectral data `spectralData1D` of size 1-by-P into the 3-D volume data `dataCube` of size 1-by-1-by-P by using the `reshape` function. The `hypercube` function then creates a 3-D hypercube object by adding the wavelength information `wavelength` to the 3-D volume data `dataCube`.

• Reshape 2-D spectral data of size M-by-P into a 3-D hypercube of size M-by-1-by-P or 1-by-M-by-P, where M represents the number of spectral reflectance curves and P is the spectral dimension. For example,

```[numSpectra,spectralDim] = size(spectralData2D); dataCube = reshape(spectralData2D,[numSpectra 1 spectralDim]); hCube = hypercube(dataCube,wavelength);```

reshapes the 2-D spectral data `spectralData2D` of size M-by-P into the 3-D volume data `dataCube` of size M-by-1-by-P by using the `reshape` function. The `hypercube` function then creates a 3-D hypercube object by adding the wavelength information `wavelength` to the 3-D volume data `dataCube`.

For more information on how to use 2-D spectral data for hyperspectral function, see Identify Vegetation and Non-Vegetation Spectra example.