Class ClusterLabeledImage
- All Implemented Interfaces:
Stoppable
Given a labeled image in which pixels that contains the same label may or may not be connected to each other, create a new labeled image in which only connected pixels have the same label. A two pass algorithm is used. In the first pass pixels are examined from top to bottom, left to right. For each pixel (the target), the input image and output image labels of its adjacent pixels are examined. If an adjacent pixel has the same input label as the target then it is either assigned the same output label or marked for being merged. Depending if it is not labeled or has an output label already, respectively. After all the pixels are process the merge requests are examined and a new set of output labels is created. A pass across the output image is done to relabel the inputs.
Clustering can be done using 4 or 8 connect, which defines what an adjacent pixel is. 4-connect just considers pixels which are (+1,0) (0,1) (-1,0) (0,-1). 8-connect considers (+1,0) (0,1) (-1,0) (0,-1) and (1,1) (-1,1) (-1,-1) (1,-1).
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.ddogleg.struct.Stoppable
Stoppable.Stopped
-
Field Summary
Modifier and TypeFieldDescriptionprotected ConnectRule
protected Point2D_I32[]
protected int[]
protected int[]
protected DogArray_I32
Fields inherited from class boofcv.alg.segmentation.ms.RegionMergeTree
mergeList, rootID, stopRequested, tmpMemberCount
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
connectBottom
(GrayS32 input, GrayS32 output) Examines pixels along the bottom borderprotected void
connectInner
(GrayS32 input, GrayS32 output) Examines pixels inside the image without the need for bounds checkingprotected void
connectLeftRight
(GrayS32 input, GrayS32 output) Examines pixels along the left and right bordervoid
process
(GrayS32 input, GrayS32 output, DogArray_I32 regionMemberCount) Relabels the image such that all pixels with the same label are a member of the same graph.protected void
setUpEdges
(GrayS32 input, GrayS32 output) Declares lookup tables for neighborsprotected void
setUpEdges4
(GrayS32 image, int[] edges) protected void
setUpEdges8
(GrayS32 image, int[] edges) Methods inherited from class boofcv.alg.segmentation.ms.RegionMergeTree
flowIntoRootNode, initializeMerge, isStopRequested, markMerge, performMerge, requestStop, setToRootNodeNewID
-
Field Details
-
connectRule
-
edgesIn
protected int[] edgesIn -
edgesOut
protected int[] edgesOut -
edges
-
regionMemberCount
-
-
Constructor Details
-
ClusterLabeledImage
Configures labeling- Parameters:
connectRule
- Which connectivity rule to use. 4 or 8
-
-
Method Details
-
setUpEdges
Declares lookup tables for neighbors -
setUpEdges8
-
setUpEdges4
-
process
Relabels the image such that all pixels with the same label are a member of the same graph.- Parameters:
input
- Labeled input image.output
- Labeled output image.regionMemberCount
- (Input/Output) Number of pixels which belong to each group.
-
connectInner
Examines pixels inside the image without the need for bounds checking -
connectLeftRight
Examines pixels along the left and right border -
connectBottom
Examines pixels along the bottom border
-