Class SplitMergeLineFit
java.lang.Object
boofcv.alg.shapes.polyline.splitmerge.SplitMergeLineFit
- Direct Known Subclasses:
SplitMergeLineFitLoop
,SplitMergeLineFitSegment
Base class for algorithm which employ a split and merge strategy to fitting a set of line segments onto an
ordered set of points. The lines are an approximation of the original shape described by the point list.
This list can either be connected at the end (looped) or not, depending on the implementation. The points
in the list are assumed to be ordered with each consecutive point connected to its neighbors. The output is
a set of indexes which correspond to points in the original list that compose the line segments. A minimum
of two indexes will be returned.
The returned set of line segments is guaranteed to match the original set of points to within a user
specified tolerance. That is, no point in the list will be more than 'tol' distance away from a line segment.
A line is split when a point between two end points is greater than the split distance. A corner is removed (two
lines merged) if the corner is less than the split distance away from two of its adjacent neighbors. The split
threshold is specified as a fraction of line distance to maximize scale invariance. The minimum split threshold
is specified in units of pixels because a simple ratio doesn't work well for small objects.
Split and merge is repeated until there is no more change or the maximum number of iterations has been reached.
-
Field Summary
Modifier and TypeFieldDescriptionprotected int
protected DogArray_B
protected @Nullable List<Point2D_I32>
protected LineParametric2D_F64
protected int
protected ConfigLength
protected int
protected Point2D_F64
protected DogArray_I32
protected double
-
Constructor Summary
ModifierConstructorDescriptionprotected
SplitMergeLineFit
(double splitFraction, ConfigLength minimumSideLength, int maxIterations) Configures algorithm -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract boolean
_process
(List<Point2D_I32> list) int
boolean
process
(List<Point2D_I32> list, DogArray_I32 vertexes) Approximates the input list with a set of line segmentsvoid
setAbortSplits
(int abortSplits) void
setMaxIterations
(int maxIterations) void
setSplitFraction
(double toleranceSplit) protected double
Computes the split threshold from the end point of two lines
-
Field Details
-
maxIterations
protected int maxIterations -
toleranceFractionSq
protected double toleranceFractionSq -
minimumSideLength
-
minimumSideLengthPixel
protected int minimumSideLengthPixel -
contour
-
line
-
point2D
-
splits
-
changed
-
abortSplits
protected int abortSplits
-
-
Constructor Details
-
SplitMergeLineFit
protected SplitMergeLineFit(double splitFraction, ConfigLength minimumSideLength, int maxIterations) Configures algorithm- Parameters:
splitFraction
- A line will be split if a point is more than this fraction of its length away from the line. Try 0.05minimumSideLength
- The minimum length of a side as a function of contour lengthmaxIterations
- Maximum number of split and merge refinements. Set to zero to disable refinement. Try 20
-
-
Method Details
-
process
Approximates the input list with a set of line segments- Parameters:
list
- (Input) Ordered list of connected points.vertexes
- (Output) Indexes in the input list which are corners in the polyline- Returns:
- true if it could fit a polygon to the points or false if not
-
_process
-
splitThresholdSq
Computes the split threshold from the end point of two lines -
setMaxIterations
public void setMaxIterations(int maxIterations) -
setSplitFraction
public void setSplitFraction(double toleranceSplit) -
getAbortSplits
public int getAbortSplits() -
setAbortSplits
public void setAbortSplits(int abortSplits)
-