public class ClusterLabeledImage extends RegionMergeTree
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).
| Modifier and Type | Field and Description |
|---|---|
protected boofcv.struct.ConnectRule |
connectRule |
protected georegression.struct.point.Point2D_I32[] |
edges |
protected int[] |
edgesIn |
protected int[] |
edgesOut |
protected org.ddogleg.struct.GrowQueue_I32 |
regionMemberCount |
mergeList, rootID, tmpMemberCount| Constructor and Description |
|---|
ClusterLabeledImage(boofcv.struct.ConnectRule connectRule)
Configures labeling
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
connectBottom(boofcv.struct.image.GrayS32 input,
boofcv.struct.image.GrayS32 output)
Examines pixels along the bottom border
|
protected void |
connectInner(boofcv.struct.image.GrayS32 input,
boofcv.struct.image.GrayS32 output)
Examines pixels inside the image without the need for bounds checking
|
protected void |
connectLeftRight(boofcv.struct.image.GrayS32 input,
boofcv.struct.image.GrayS32 output)
Examines pixels along the left and right border
|
void |
process(boofcv.struct.image.GrayS32 input,
boofcv.struct.image.GrayS32 output,
org.ddogleg.struct.GrowQueue_I32 regionMemberCount)
Relabels the image such that all pixels with the same label are a member of the same graph.
|
protected void |
setUpEdges(boofcv.struct.image.GrayS32 input,
boofcv.struct.image.GrayS32 output)
Declares lookup tables for neighbors
|
protected void |
setUpEdges4(boofcv.struct.image.GrayS32 image,
int[] edges) |
protected void |
setUpEdges8(boofcv.struct.image.GrayS32 image,
int[] edges) |
flowIntoRootNode, initializeMerge, markMerge, performMerge, setToRootNodeNewIDprotected boofcv.struct.ConnectRule connectRule
protected int[] edgesIn
protected int[] edgesOut
protected georegression.struct.point.Point2D_I32[] edges
protected org.ddogleg.struct.GrowQueue_I32 regionMemberCount
public ClusterLabeledImage(boofcv.struct.ConnectRule connectRule)
connectRule - Which connectivity rule to use. 4 or 8protected void setUpEdges(boofcv.struct.image.GrayS32 input,
boofcv.struct.image.GrayS32 output)
protected void setUpEdges8(boofcv.struct.image.GrayS32 image,
int[] edges)
protected void setUpEdges4(boofcv.struct.image.GrayS32 image,
int[] edges)
public void process(boofcv.struct.image.GrayS32 input,
boofcv.struct.image.GrayS32 output,
org.ddogleg.struct.GrowQueue_I32 regionMemberCount)
input - Labeled input image.output - Labeled output image.regionMemberCount - (Input/Output) Number of pixels which belong to each group.protected void connectInner(boofcv.struct.image.GrayS32 input,
boofcv.struct.image.GrayS32 output)
protected void connectLeftRight(boofcv.struct.image.GrayS32 input,
boofcv.struct.image.GrayS32 output)
protected void connectBottom(boofcv.struct.image.GrayS32 input,
boofcv.struct.image.GrayS32 output)