boofcv.alg.shapes.polyline
Class SplitMergeLineFit
- java.lang.Object
-
- boofcv.alg.shapes.polyline.SplitMergeLineFit
-
- Direct Known Subclasses:
- SplitMergeLineFitLoop, SplitMergeLineFitSegment
public abstract class SplitMergeLineFit extends java.lang.ObjectBase 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.
-
-
Constructor Summary
Constructors Constructor and Description SplitMergeLineFit(double splitFraction, double minimumSideLengthFraction, int maxIterations)Configures algorithm
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method and Description intgetAbortSplits()doublegetMinimumSideLengthFraction()GrowQueue_I32getSplits()List of point indexes in the contour.abstract booleanprocess(java.util.List<Point2D_I32> list)Approximates the input list with a set of line segmentsvoidsetAbortSplits(int abortSplits)voidsetMaxIterations(int maxIterations)voidsetMinimumSideLengthFraction(double minimumSideLengthFraction)voidsetSplitFraction(double toleranceSplit)
-
-
-
Constructor Detail
-
SplitMergeLineFit
public SplitMergeLineFit(double splitFraction, double minimumSideLengthFraction, 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.05minimumSideLengthFraction- 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 Detail
-
process
public abstract boolean process(java.util.List<Point2D_I32> list)
Approximates the input list with a set of line segments- Parameters:
list- Ordered list of connected points.- Returns:
- true if it could fit a polygon to the points or false if not
-
getSplits
public GrowQueue_I32 getSplits()
List of point indexes in the contour. Each point is the end of a line segment. A minimum of two points will be returned. NOTE: This list is modified the next time process is called.- Returns:
- List of indexes
-
setMaxIterations
public void setMaxIterations(int maxIterations)
-
setSplitFraction
public void setSplitFraction(double toleranceSplit)
-
getAbortSplits
public int getAbortSplits()
-
setAbortSplits
public void setAbortSplits(int abortSplits)
-
getMinimumSideLengthFraction
public double getMinimumSideLengthFraction()
-
setMinimumSideLengthFraction
public void setMinimumSideLengthFraction(double minimumSideLengthFraction)
-
-
DataMelt 3.0 © DataMelt by jWork.ORG