Package boofcv.alg.shapes.polyline
Class MinimizeEnergyPrune
java.lang.Object
boofcv.alg.shapes.polyline.MinimizeEnergyPrune
Prunes corners from a pixel level accuracy contour by minizing a penalized energy function. The energy of a line segment is defined as Euclidean distance squared of each point from the line summed plus a penalty divided by the distance between two end points of the line. When a corner is removed the location of its neighbors are optimized again.
Energy of line segment = [Sum( distance points from line squared) + penalty ] / (segment length)
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected int
circularDistance
(int start, int end) Distance the two points are apart in clockwise directionprotected double
computeSegmentEnergy
(DogArray_I32 corners, int cornerA, int cornerB) Computes the energy for a segment defined by the two corner indexesprotected double
energyRemoveCorner
(int removed, DogArray_I32 corners) Returns the total energy after removing a cornerprotected Point2D_I32
getContour
(int index) boolean
prune
(List<Point2D_I32> contour, DogArray_I32 input, DogArray_I32 output) Given a contour and initial set of corners compute a new set of corner indexes
-
Constructor Details
-
MinimizeEnergyPrune
public MinimizeEnergyPrune(double splitPenalty)
-
-
Method Details
-
prune
Given a contour and initial set of corners compute a new set of corner indexes- Parameters:
contour
- List of points in the shape's contourinput
- Initial set of cornersoutput
- Pruned set of corners- Returns:
- true if one or more corners were pruned, false if nothing changed
-
energyRemoveCorner
Returns the total energy after removing a corner- Parameters:
removed
- index of the corner that is being removedcorners
- list of corner indexes
-
computeSegmentEnergy
Computes the energy for a segment defined by the two corner indexes -
getContour
-
circularDistance
protected int circularDistance(int start, int end) Distance the two points are apart in clockwise direction
-