Main Content

imsegisodata

ISODATA clustering based image segmentation

Since R2024b

    Description

    The iterative self-organizing data analysis technique (ISODATA) algorithm is a method used in pattern recognition and image analysis for clustering multivariate data into naturally occurring groups. Developed as an extension of the k-means clustering algorithm, ISODATA clusters data by iteratively adjusting clusters and automatically determining their optimal number. Compared to the k-means image segmentation of the imsegkmeans function, the ISODATA image segmentation of imsegisodata is more flexible and powerful, particularly in handling real-world, complex, and varied data sets, where the number of clusters is not already known.

    [L,centers] = imsegisodata(I) segments image I into clusters by performing ISODATA clustering, and returns the segmented labeled output in L and cluster centers in centers.

    example

    [L,centers] = imsegisodata(I,Name=Value) fine-tunes the ISODATA algorithm using one or more optional name-value arguments. For example, InitialNumClusters=5 starts the clustering process with five clusters.

    example

    Examples

    collapse all

    Read a 2-D grayscale image into the workspace.

    I = imread("cameraman.tif");

    Segment the image using ISODATA clustering.

    [L,centers] = imsegisodata(I);

    Visualize the image and its segmentation.

    figure
    tiledlayout(1,2)
    nexttile
    imshow(I)
    nexttile
    imagesc(L)
    axis equal tight

    Figure contains 2 axes objects. Axes object 1 contains an object of type image. Hidden axes object 2 contains an object of type image.

    Read a 2-D RGB image into the workspace.

    I = imread("peppers.png");

    Segment the image using ISODATA clustering.

    [L,centers] = imsegisodata(I,NormalizeInput=false,MaxPairsToMerge=3);

    Visualize the image and its segmentation.

    figure
    tiledlayout(1,2)
    nexttile
    imshow(I)
    nexttile
    imagesc(L)
    axis equal tight

    Figure contains 2 axes objects. Axes object 1 contains an object of type image. Hidden axes object 2 contains an object of type image.

    Import a 2-D hyperspectral image into the workspace.

    I = hypercube("paviaU.dat");

    Segment the image using ISODATA clustering.

    [L,centers] = imsegisodata(I,InitialNumClusters=10,MaxIterations=30,MinSamples=50,MaxStandardDeviation=2,MinClusterSeparation=3);

    Visualize the RGB image and its segmentation.

    rgbI = colorize(I,Method="rgb",ContrastStretching=true);
    figure
    tiledlayout(1,2)
    nexttile
    imshow(rgbI)
    nexttile
    imagesc(L)
    axis equal tight

    Figure contains 2 axes objects. Axes object 1 contains an object of type image. Hidden axes object 2 contains an object of type image.

    Input Arguments

    collapse all

    Image to segment, specified as a 2-D grayscale image, 2-D RGB image, 2-D hyperspectral image, or a hypercube object.

    Note

    To read the hyperspectral image as a hypercube object, you must have 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.

    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: imsegisodata(I,InitialNumClusters=5) starts the clustering process with five clusters.

    Normalize input data, specified as a numeric or logical 1 (true) or 0 (false). If you specify NormalizeInput as true, the function normalizes each channel of the image individually to zero mean and unit variance. Consider normalizing the input image if each channel of the image has a different intensity range.

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

    Initial number of clusters, specified as a positive integer. The ISODATA algorithm starts with the specified number of clusters, and splits or merges the clusters as iterations progress to reach an optimal number of clusters. An initial number of clusters close to the optimal number of clusters can improve accuracy.

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

    Maximum number of iterations, specified as a positive integer. Increasing the maximum number of iterations increases the accuracy of the ISODATA algorithm and the time required for execution. However, depending on the input image, the accuracy might not increase significantly beyond a certain number of iterations.

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

    Minimum number of samples in a class, specified as a positive integer. If the input image has size M-by-N-by-C, where M is the number of rows, N is the number of columns, and C is the number of channels or bands, the default value of MinSamples is M*N/(10*InitialNumClusters). The function removes a cluster if it has fewer than MinSamples samples. If smaller clusters have significance in your input image, decrease the value of MinSamples. Increase the value of MinSamples to ignore smaller clusters.

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

    Maximum standard deviation of a class, specified as a nonnegative scalar. If you specify NormalizeInput as true, the default value of MaxStandardDeviation is 1. If you specify NormalizeInput as false, the default value of MaxStandardDeviation is the standard deviation of the input image. If the standard deviation of the samples within a cluster is greater than MaxStandardDeviation, the function splits the cluster into two. Decrease the value if you want low variability in a cluster. Increase the value to allow large variability in a cluster.

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

    Minimum cluster separation, specified as a nonnegative scalar. If the distance between two cluster centers is less than or equal to MinClusterSeparation, the function merges the clusters. Decrease the value if you want low variability in a cluster. Increase the value to allow large variability in a cluster.

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

    Maximum number of eligible cluster pairs to merge per iteration, specified as a positive integer.

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

    Output Arguments

    collapse all

    Label image, returned as a 2-D matrix of positive integers. If the input image has size M-by-N-by-C, where M is the number of rows, N is the number of columns, and C is the number of channels or bands, then the size of L is M-by-N.

    Data Types: double

    Cluster centers, returned as a numeric matrix of the same data type as the input image. The matrix is of size K-by-C, where K is the optimal number of clusters finalized by the function and C is the number of channels or bands in the input image.

    Algorithms

    The imsegisodata function segments the image I using these steps, and returns the assigned cluster labels L and cluster centers centers.

    • Normalization — You can choose to normalize the input image, if the channels of the image have different intensity ranges, by specifying the NormalizeInput name-value argument as true.

    • Initialization — The function starts with an initial set of cluster centers, which you can select randomly or based on prior knowledge. The function assigns each pixel to the nearest cluster center based on the Euclidean distance. You can specify the initial number of clusters by using the InitialNumClusters name-value argument.

    • Update — After the function completes the initial assignment of each pixel to a cluster, it iteratively removes empty clusters, splits clusters, and merges clusters until it reaches a stopping criterion such as the maximum number of iterations specified by MaxIterations. After each update, the function recalculates each cluster center as the mean of the pixels in that cluster.

    • Remove Small Clusters — The function removes clusters that have fewer than MinSamples pixels.

    • Splitting Clusters — The function evaluates each cluster to determine whether to split it into two. It splits a cluster into two based on several criteria, such as if the standard deviation of the pixels within the cluster is greater than MaxStandardDeviation.

    • Merging Clusters — The function evaluates whether to merge any pairs of clusters. It merges two clusters if the distance between their centers is less than or equal to MinClusterSeparation. The center of the merged cluster is the weighted average of the cluster centers of the two clusters that are merged. The function merges at most MaxPairsToMerge cluster pairs per iteration.

    Depending on the parameters specified for the ISODATA algorithm, segmentation using the imsegisodata function may be time-consuming or may spiral out of control leaving only one class, if the data is very unstructured.

    References

    [1] Tou, Julius T., and Rafael C. Gonzalez. Pattern Recognition Principles. Applied Mathematics and Computation, No. 7. Reading, Mass: Addison-Wesley Pub. Co, 1974.

    Version History

    Introduced in R2024b

    See Also