3-D superpixel oversegmentation of 3-D image

`[`

computes
superpixels of image `L`

,`NumLabels`

]
= superpixels3(___,`Name,Value`

,...)`A`

using Name-Value pairs
to control aspects of the segmentation.

The algorithm used in `superpixels3`

is a
modified version of the Simple Linear Iterative Clustering (SLIC)
algorithm used by `superpixels`

. At a high level,
it creates cluster centers and then iteratively alternates between
assigning pixels to the closest cluster center and updating the locations
of the cluster centers. `superpixels3`

uses a
distance metric to determine the closest cluster center for each pixel.
This distance metric combines intensity distance and spatial distance.

The function's `Compactness`

argument comes
from the mathematical form of the distance metric. The compactness
parameter of the algorithm is a scalar value that controls the shape
of the superpixels. The distance between two pixels *i* and *j*,
where *m* is the compactness value, is:

$$\begin{array}{l}{d}_{\mathrm{int}ensity}=\sqrt{{\left({l}_{i}-{l}_{j}\right)}^{2}}\\ {d}_{spatial}=\sqrt{{({x}_{i}-{x}_{j})}^{2}+{({y}_{i}-{y}_{j})}^{2}+{({z}_{i}-{z}_{j})}^{2}}\\ D=\sqrt{{(\frac{{d}_{\mathrm{int}ensity}}{m})}^{2}+{(\frac{{d}_{spatial}}{S})}^{2}}\end{array}$$

Compactness has the same meaning as in the 2-D `superpixels`

function:
It determines the relative importance of the intensity distance and
the spatial distance in the overall distance metric. A lower value
makes the superpixels adhere to boundaries better, making them irregularly
shaped. A higher value makes the superpixels more regularly shaped.
The allowable range for compactness is `(0 Inf)`

,
as in the 2-D function. The typical range has been found through experimentation
to be `[0.01 0.1]`

. The dynamic range of input images
is normalized within the algorithm to be from 0 to 1. This enables
a consistent meaning of compactness values across images.

`boundarymask`

| `imoverlay`

| `label2idx`

| `label2rgb`

| `superpixels`