Main Content

hyperslic

2-D superpixel oversegmentation of hyperspectral images

Since R2023b

    Description

    The simple linear iterative clustering (SLIC) algorithm performs superpixel oversegmentation of images. While the superpixels and superpixels3 functions apply SLIC to 2-D grayscale or RGB images and 3-D volumes, respectively, they are not suitable for use on hyperspectral images, because hyperspectral images have a large number of spectral bands. Using superpixels on the just three spectral bands of the hyperspectral image may not capture the information in the several other spectral bands of the hyperspectral image. The hyperslic function extends the SLIC algorithm to 2-D superpixel segmentation of hyperspectral images by considering the information in these spectral bands. You can use the superpixel regions provided by the hyperslic function to reduce the complexity of further segmentation.

    [L,numLabels] = hyperslic(hCube,K) performs 2-D superpixel oversegmentation of the hyperspectral image hCube, where K is the number of superpixels you want to create. The function returns the label matrix L and the actual number of computed superpixels, numLabels.

    example

    [L,numLabels] = hyperslic(hCube,K,Name=Value) fine-tunes the behavior of the function using one or more optional name-value arguments. For example, NumIterations=20 specifies to perform 20 iterations during the clustering phase of the SLIC algorithm.

    Note

    This function requires the Hyperspectral Imaging Library for Image Processing Toolbox™. You can install the Hyperspectral Imaging Library for Image Processing Toolbox from Add-On Explorer. For more information about installing add-ons, see Get and Manage Add-Ons.

    The Hyperspectral Imaging Library for Image Processing Toolbox requires desktop MATLAB®, as MATLAB Online™ or MATLAB Mobile™ do not support the library.

    Examples

    collapse all

    Read a hyperspectral image into the workspace.

    hCube = hypercube("paviaU.dat");

    Perform 2-D superpixel oversegmentation of the hyperspectral image with a desired output of 185 superpixels.

    [L,numLabels] = hyperslic(hCube,185);

    Display the boundaries of the label regions overlaid on an RGB image constructed from the hyperspectral image.

    BW = boundarymask(L);
    rgbImg = colorize(hCube,Method="rgb",ContrastStretching=true);
    I = imoverlay(rgbImg,BW,"cyan");
    figure
    imshow(I)

    Figure contains an axes object. The hidden axes object contains an object of type image.

    Input Arguments

    collapse all

    Hyperspectral image, specified as a hypercube object or 3-D numeric array that represents a hyperspectral data cube of size M-by-N-by-C. The number of spectral bands C in the hyperspectral data must be greater than or equal to 3. If C is exactly 3, you must specify the name-value argument IsInputDimReduced as true.

    Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

    Desired number of superpixels, specified as a positive integer.

    Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

    Name-Value Arguments

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Example: hyperslic(hCube,K,IsInputDimReduced=true,NumIterations=20) performs 2-D superpixel oversegmentation for 20 iterations without the preprocessing step of spectral dimensionality reduction.

    Hyperspectral image has reduced dimensions, specified as a numeric or logical 1 (true) or 0 (false). Specify IsInputDimReduced as true if you have already reduced the spectral dimensions of the hyperspectral image. If you specify IsInputDimReduced as false, the function performs spectral dimensionality reduction of the hyperspectral image before superpixel oversegmentation. If you specify IsInputDimReduced as true, the function directly performs superpixel oversegmentation.

    Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

    Number of iterations used in the clustering phase of the algorithm, specified as a positive integer less than or equal to 30.

    Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

    Output Arguments

    collapse all

    Label matrix, returned as a 2-D numeric matrix of the same spatial dimensions as the hyperspectral data. If the hyperspectral data is of size M-by-N-by-C, then the label matrix L is of size M-by-N. The value at each location in L indicates the label of the corresponding pixel in the hyperspectral data.

    Data Types: double

    Number of superpixels computed, returned as a positive integer.

    Data Types: double

    Algorithms

    The hyperslic function extends the SLIC algorithm to 2-D superpixel segmentation of hyperspectral images by considering the information in the spectral bands. To improve the speed of the SLIC algorithm for hyperspectral images without losing much spectral information, the hyperslic function preprocesses the specified hyperspectral image to reduce its spectral dimensions method before using the extended SLIC algorithm for segmentation. However, if the number of spectral bands, after spectral dimensionality reduction, is fewer than three, the hyperslic function performs the 2-D superpixel oversegmentation by using the superpixels function on the mean image along the spectral dimension.

    References

    [1] Achanta, R., A. Shaji, K. Smith, A. Lucchi, P. Fua, and Sabine Süsstrunk. “SLIC Superpixels Compared to State-of-the-Art Superpixel Methods.” IEEE Transactions on Pattern Analysis and Machine Intelligence 34, no. 11 (November 2012): 2274–82. https://doi.org/10.1109/TPAMI.2012.120.

    [2] Xu, Xiang, Jun Li, Changshan Wu, and Antonio Plaza. “Regional Clustering-Based Spatial Preprocessing for Hyperspectral Unmixing.” Remote Sensing of Environment 204 (January 2018): 333–46. https://doi.org/10.1016/j.rse.2017.10.020.

    Version History

    Introduced in R2023b

    expand all