Skip to main content
. 2019 Jan 24;19(3):479. doi: 10.3390/s19030479
Algorithm 1 SLIC superpixel segmentation.
  • Input: 

    Processed HSIs image XRN×M, Desired number of approximately superpixels K.

  •   1:

    Initialize cluster centers Ck=[lk,ak,bk,xk,yk]T by sampling pixels at regular grid steps S.

  •   2:

    Move cluster centers to the lowest gradient position in a 3×3 neighborhood.

  •   3:

    Set label l(i)=1 for each pixel i.

  •   4:

    Set distance d(i)= for each pixel i.

  •   5:

    Repeat

  •   6:

    for each cluster center Ck do

  •   7:

        for each pixel i in a 2S×2S region around Ck do

  •   8:

            Compute the distance D between Ck and i.

  •   9:

            if D<d(i) then

  •  10:

               set d(i)=D

  •  11:

               set l(i)=k

  •  12:

            end if

  •  13:

        end for

  •  14:

    end for

  •  15:

    Compute new cluster centers.

  •  16:

    Compute residual error E.

  •  17:

    UntilEthreshold.

  •  18:

    Enforce connectivity.

  • Output: 

    Superpixel segmentations.