public class LinearContourLabelChang2004
extends java.lang.Object
Finds objects in a binary image by tracing their contours. The output is labeled binary image, set of external and internal contours for each object/blob. Blobs can be defined using a 4 or 8 connect rule. The algorithm works by processing the image in a single pass. When a new object is encountered its contour is traced. Then the inner pixels are labeled. If an internal contour is found it will also be traced. See [1] for all the details. The original algorithm has been modified to use different connectivity rules.
Output: Background pixels (0 in input image) are assigned a value of 0, Each blob is then assigned a unique ID starting from 1 up to the number of blobs.
Internally, the input binary image is copied into another image which will have a 1 pixel border of all zeros around it. This ensures that boundary checks will not need to be done, speeding up the algorithm by about 25%.
[1] Fu Chang and Chun-jen Chen and Chi-jen Lu, "A linear-time component-labeling algorithm using contour tracing technique" Computer Vision and Image Understanding, 2004
| Constructor and Description |
|---|
LinearContourLabelChang2004(ConnectRule rule)
Configures the algorithm.
|
| Modifier and Type | Method and Description |
|---|---|
org.ddogleg.struct.FastQueue<Contour> |
getContours() |
void |
process(GrayU8 binary,
GrayS32 labeled)
Processes the binary image to find the contour of and label blobs.
|
public LinearContourLabelChang2004(ConnectRule rule)
rule - Connectivity rule. 4 or 8public void process(GrayU8 binary, GrayS32 labeled)
binary - Input binary image. Not modified.labeled - Output. Labeled image. Modified.public org.ddogleg.struct.FastQueue<Contour> getContours()