public class RefinePolyLineCorner
extends java.lang.Object
Optimizing corner placements to a pixel level when given a contour and integer list of approximate
corner locations which define set of line segments. Corners are optimized by searching for another near by
pixel in the provided contour which reduces the distance of the contour from the line segments. This
is intended to optimize the output from SplitMergeLineFit. Can be configured to
handle case where line segments form a loop or have disconnected end points.
Each corner is individually optimized once per iteration. The process is repeated until the maximum number of iterations has been reached or there is no change in corner placements.
| Modifier and Type | Field and Description |
|---|---|
protected int |
searchRadius |
| Constructor and Description |
|---|
RefinePolyLineCorner(boolean looping)
Constructor using default parameters
|
RefinePolyLineCorner(boolean looping,
int maxIterations)
Constructor with configurable parameters
|
| Modifier and Type | Method and Description |
|---|---|
protected double |
computeCost(java.util.List<georegression.struct.point.Point2D_I32> contour,
int c0,
int c1,
int c2,
int offset)
Computes the distance between the two lines defined by corner points in the contour
|
protected static double |
distance(georegression.struct.line.LineGeneral2D_F64 line,
georegression.struct.point.Point2D_I32 p)
If A*A + B*B == 1 then a simplified distance formula can be used
|
protected double |
distanceSum(georegression.struct.line.LineGeneral2D_F64 line,
int c0,
int c1,
java.util.List<georegression.struct.point.Point2D_I32> contour)
Sum of Euclidean distance of contour points along the line
|
boolean |
fit(java.util.List<georegression.struct.point.Point2D_I32> contour,
org.ddogleg.struct.GrowQueue_I32 corners)
Fits a polygon to the contour given an initial set of candidate corners.
|
protected int |
optimize(java.util.List<georegression.struct.point.Point2D_I32> contour,
int c0,
int c1,
int c2)
Searches around the current c1 point for the best place to put the corner
|
public RefinePolyLineCorner(boolean looping,
int maxIterations)
looping - true if it loops or false if notmaxIterations - Number of internal EM iterationspublic RefinePolyLineCorner(boolean looping)
public boolean fit(java.util.List<georegression.struct.point.Point2D_I32> contour,
org.ddogleg.struct.GrowQueue_I32 corners)
contour - Contours around the shapecorners - (Input) initial set of corners. (output) refined set of cornersprotected int optimize(java.util.List<georegression.struct.point.Point2D_I32> contour,
int c0,
int c1,
int c2)
protected double computeCost(java.util.List<georegression.struct.point.Point2D_I32> contour,
int c0,
int c1,
int c2,
int offset)
contour - list of contour pointsc0 - end point of line 0c1 - start of line 0 and 1c2 - end point of line 1offset - added to c1 to make start of linesprotected double distanceSum(georegression.struct.line.LineGeneral2D_F64 line,
int c0,
int c1,
java.util.List<georegression.struct.point.Point2D_I32> contour)
protected static double distance(georegression.struct.line.LineGeneral2D_F64 line,
georegression.struct.point.Point2D_I32 p)