Class SegmentSlic<T extends ImageBase>
- java.lang.Object
-
- boofcv.alg.segmentation.slic.SegmentSlic<T>
-
- Direct Known Subclasses:
- SegmentSlic_F32, SegmentSlic_PlF32, SegmentSlic_PlU8, SegmentSlic_U8
public abstract class SegmentSlic<T extends ImageBase> extends java.lang.ObjectK-means based superpixel image segmentation, see [1]. The image is broken up into superpixels (clusters of connected pixels) in a grid like pattern. A connectivity rule of 4 or 8 is enforced across all the clusters. Clustering is done using k-means, where each point is composed on the 2D image coordinate and an intensity value in each color band, thus K = 2+numBands. Instead of computing the distance of each cluster's center from each point only points within a distance of S si considered. The difference in scale difference between pixels and image intensity is handled through a user configurable tuning parameter.
Deviations from paper:
- In the paper a LAB color space is always used. In this implementation a general purpose N-dimensional color space is used.
- To correctly support LAB or other color spaces a specialized implementation might be needed to ensure the intensity of a pixel is computed correctly.
- Small regions are merged into other regions based on how similar their color is. In the paper a small region is merged into the largest region it is connected to.
[1] Radhakrishna Achanta, Appu Shaji, Kevin Smith, Aurelien Lucchi, Pascal Fua, and Sabine Süsstrunk, SLIC Superpixels, EPFL Technical Report no. 149300, June 2010.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static classSegmentSlic.ClusterThe mean in k-means.static classSegmentSlic.ClusterDistanceStores how far a cluster is from the specified pixelstatic classSegmentSlic.PixelK-means clustering information for each pixel.
-
Field Summary
Fields Modifier and Type Field and Description static intBORDER
-
Constructor Summary
Constructors Constructor and Description SegmentSlic(int numberOfRegions, float m, int totalIterations, ConnectRule connectRule, ImageType<T> imageType)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method and Description abstract voidaddColor(float[] color, int index, float weight)Performs a weighted add to the cluster's color at the specified pixel in the imagevoidassignLabelsToPixels(GrayS32 pixelToRegions, GrowQueue_I32 regionMemberCount, FastQueue<float[]> regionColor)Selects which region each pixel belongs to based on which cluster it is the closest toabstract floatcolorDistance(float[] color, int index)Euclidean Squared distance away that the pixel is from the provided colorFastQueue<SegmentSlic.Cluster>getClusters()ConnectRulegetConnectRule()ImageType<T>getImageType()abstract floatgetIntensity(int x, int y)Intensity of the pixel at the specified locationGrowQueue_I32getRegionMemberCount()voidprocess(T input, GrayS32 output)abstract voidsetColor(float[] color, int x, int y)Sets the cluster's to the pixel color at that location
-
-
-
Field Detail
-
BORDER
public static final int BORDER
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SegmentSlic
public SegmentSlic(int numberOfRegions, float m, int totalIterations, ConnectRule connectRule, ImageType<T> imageType)
-
-
Method Detail
-
setColor
public abstract void setColor(float[] color, int x, int y)Sets the cluster's to the pixel color at that location
-
addColor
public abstract void addColor(float[] color, int index, float weight)Performs a weighted add to the cluster's color at the specified pixel in the image
-
colorDistance
public abstract float colorDistance(float[] color, int index)Euclidean Squared distance away that the pixel is from the provided color
-
getIntensity
public abstract float getIntensity(int x, int y)Intensity of the pixel at the specified location
-
assignLabelsToPixels
public void assignLabelsToPixels(GrayS32 pixelToRegions, GrowQueue_I32 regionMemberCount, FastQueue<float[]> regionColor)
Selects which region each pixel belongs to based on which cluster it is the closest to
-
getRegionMemberCount
public GrowQueue_I32 getRegionMemberCount()
-
getClusters
public FastQueue<SegmentSlic.Cluster> getClusters()
-
getConnectRule
public ConnectRule getConnectRule()
-
-
DataMelt 3.0 © DataMelt by jWork.ORG