Class LinearContourLabelChang2004
- java.lang.Object
-
- boofcv.alg.filter.binary.LinearContourLabelChang2004
-
public class LinearContourLabelChang2004 extends java.lang.ObjectFinds 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.
The maximum contour size says how many elements are allowed in a contour. if that number is exceeded by the external contour the external contour will be zeroed. Internal contours that exceed it will be discarded. Note that the all external and internal contours will still be traversed they will just not be recorded if too large.
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 Summary
Constructors Constructor Description LinearContourLabelChang2004(boofcv.struct.ConnectRule rule)Configures the algorithm.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boofcv.struct.ConnectRulegetConnectRule()org.ddogleg.struct.FastQueue<ContourPacked>getContours()intgetMaxContourSize()intgetMinContourSize()boofcv.struct.PackedSetsPoint2D_I32getPackedPoints()booleanisSaveInternalContours()voidprocess(boofcv.struct.image.GrayU8 binary, boofcv.struct.image.GrayS32 labeled)Processes the binary image to find the contour of and label blobs.voidsetConnectRule(boofcv.struct.ConnectRule rule)voidsetMaxContourSize(int maxContourSize)voidsetMinContourSize(int minContourSize)voidsetSaveInternalContours(boolean saveInternalContours)
-
-
-
Method Detail
-
process
public void process(boofcv.struct.image.GrayU8 binary, boofcv.struct.image.GrayS32 labeled)Processes the binary image to find the contour of and label blobs.- Parameters:
binary- Input binary image. Not modified.labeled- Output. Labeled image. Modified.
-
getContours
public org.ddogleg.struct.FastQueue<ContourPacked> getContours()
-
getPackedPoints
public boofcv.struct.PackedSetsPoint2D_I32 getPackedPoints()
-
getMinContourSize
public int getMinContourSize()
-
setMinContourSize
public void setMinContourSize(int minContourSize)
-
getMaxContourSize
public int getMaxContourSize()
-
setMaxContourSize
public void setMaxContourSize(int maxContourSize)
-
isSaveInternalContours
public boolean isSaveInternalContours()
-
setSaveInternalContours
public void setSaveInternalContours(boolean saveInternalContours)
-
setConnectRule
public void setConnectRule(boofcv.struct.ConnectRule rule)
-
getConnectRule
public boofcv.struct.ConnectRule getConnectRule()
-
-