Main Content

hyperseganchor

Segment hyperspectral images using fast spectral clustering with anchor graphs

Since R2024a

    Description

    You can segment a hyperspectral image using both spectral and spatial information with the fast spectral clustering with anchor graph (FSCAG) algorithm.

    L = hyperseganchor(hCube,K) segments the hyperspectral image hCube into the specified number of clusters K.

    example

    L = hyperseganchor(hCube,K,Name=Value) fine-tunes the behavior of the function using one or more optional name-value arguments. For example, MaxIterations=50 specifies to perform a maximum of 50 iterations in the clustering phase.

    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");

    Segment the hyperspectral image into 10 clusters.

    L = hyperseganchor(hcube,10);

    Display the labels of the clusters overlaid on an RGB image constructed from the hyperspectral image.

    rgbImg = colorize(hcube,Method="rgb");
    B = labeloverlay(rgbImg,L);
    figure
    imshow(B)
    title("Labeled Image")

    Figure contains an axes object. The hidden axes object with title Labeled Image 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 pixels in each layer M×N and the number of anchors NumAnchor must satisfy the condition M×N ≥ 2NumAnchors.

    Number of clusters, specified as a positive integer. The number of clusters K and the number of anchors NumAnchor must satisfy the condition K ≤ 2NumAnchors.

    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: hyperseganchor(hCube,K,MaxIterations=50) performs segmentation with a maximum of 50 iterations in the clustering phase of the FSCAG algorithm.

    Number of anchors, specified as a nonnegative integer. The function generates 2NumAnchors anchor points for the anchor graph. The number of pixels in each layer of the image M×N, the number of clusters K, and the number of neighbors NumNeighbor must satisfy these conditions.

    • M×N ≥ 2NumAnchors

    • K ≤ 2NumAnchors

    • NumNeighbor ≤ 2NumAnchors– 1

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

    Number of neighbors, specified as a nonnegative integer. The function considers NumNeighbor neighbors for each pixel when constructing the anchor graph. The number of neighbors NumNeighbor and the number of anchors NumAnchor must satisfy the condition NumNeighbor ≤ 2NumAnchors – 1.

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

    Number of attempts, specified as a positive integer. This value is the number of times the function repeats the clustering process using new initial cluster centroid positions.

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

    Maximum number of iterations in the clustering phase, specified as a positive integer.

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

    Desired accuracy, specified as a positive scalar. If the function achieves the desired accuracy before reaching the maximum number of iterations, it stops the algorithm. Lower values of Threshold indicate a higher desired accuracy.

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

    Output Arguments

    collapse all

    Label matrix, returned as a numeric matrix of size M-by-N for a hyperspectral data cube of size M-by-N-by-C. The data type of the label matrix L depends on the number of clusters K.

    • Data type of L is uint8 if K ≤ 255.

    • Data type of L is uint16 if 256 ≤ K ≤ 65535.

    • Data type of L is uint32 if 65536 ≤ K ≤ 232-1.

    • Data type of L is double if 232K.

    Algorithms

    The FSCAG algorithm constructs an anchor graph between the pixel spectra and the spectra of the anchor points. The algorithm measures the similarity between the pixel spectra and the spectra of the anchor points using both spectral and spatial information, and creates a sparse similarity matrix. The algorithm performs iterative spectral clustering of this similarity matrix to cluster the pixels in the hyperspectral image.

    References

    [1] Wang, Rong, Feiping Nie, and Weizhong Yu. “Fast Spectral Clustering With Anchor Graph for Large Hyperspectral Images.” IEEE Geoscience and Remote Sensing Letters 14, no. 11 (November 2017): 2003–7. https://doi.org/10.1109/LGRS.2017.2746625.

    [2] Wang, Cheng-Long, Feiping Nie, Rong Wang, and Xuelong Li. “Revisiting Fast Spectral Clustering with Anchor Graph.” In ICASSP 2020 - 2020 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), 3902–6. Barcelona, Spain: IEEE, 2020. https://doi.org/10.1109/ICASSP40776.2020.9053271.

    Version History

    Introduced in R2024a