public class RefinePolygonLineToImage<T extends boofcv.struct.image.ImageSingleBand>
extends java.lang.Object
Improves the fits of a polygon's which is darker or lighter than the background. Polygon's edges are assumed to be perfectly straight lines. The edges are processed individually and fit to a line using weighted regression. Both black squares with white backgrounds and white shapes with black backgrounds can be found. The edges are selected to maximize the difference between light and dark regions.
For example, assume an image axis aligned rectangle has a lower extent of 1,2 and a upper extent of 12,15, is entirely filled, excluding the upper extent (as is typical). Then the found lower and upper extends of the found polygon will also be 1,2 and 12,15.
For input polygons which are in undistorted coordinates by with a distorted image call getSnapToEdge()
and invoke BaseIntegralEdge.setTransform(PixelTransform_F32).
| Constructor and Description |
|---|
RefinePolygonLineToImage(double cornerOffset,
int lineSamples,
int sampleRadius,
int maxIterations,
double convergeTolPixels,
boolean fitBlack,
java.lang.Class<T> imageType)
Constructor which provides full access to all parameters.
|
RefinePolygonLineToImage(int numSides,
boolean fitBlack,
java.lang.Class<T> imageType)
Simplified constructor which uses reasonable default values for most variables
|
| Modifier and Type | Method and Description |
|---|---|
SnapToEdge<T> |
getSnapToEdge() |
boolean |
isFitBlack()
True if it is fitting black to the image
|
protected boolean |
optimize(georegression.struct.point.Point2D_F64 a,
georegression.struct.point.Point2D_F64 b,
georegression.struct.line.LineGeneral2D_F64 found)
Fits a line defined by the two points.
|
protected boolean |
optimize(georegression.struct.shapes.Polygon2D_F64 seed,
georegression.struct.shapes.Polygon2D_F64 current)
Refines the initial line estimates using EM.
|
boolean |
refine(georegression.struct.shapes.Polygon2D_F64 input,
georegression.struct.shapes.Polygon2D_F64 output)
Refines the fit a polygon by snapping it to the edges.
|
void |
setImage(T image)
Sets the image which is going to be processed.
|
protected T extends boofcv.struct.image.ImageSingleBand image
public RefinePolygonLineToImage(double cornerOffset,
int lineSamples,
int sampleRadius,
int maxIterations,
double convergeTolPixels,
boolean fitBlack,
java.lang.Class<T> imageType)
public RefinePolygonLineToImage(int numSides,
boolean fitBlack,
java.lang.Class<T> imageType)
numSides - Number of sides on the polygonfitBlack - If true it's fitting a black square with a white background. false is the inverse.imageType - Type of input image it processespublic void setImage(T image)
BaseIntegralEdge.setTransform(boofcv.struct.distort.PixelTransform_F32) should be called before this.public boolean refine(georegression.struct.shapes.Polygon2D_F64 input,
georegression.struct.shapes.Polygon2D_F64 output)
input - (input) Initial estimate for the polygon. Vertexes must be in clockwise order.output - (output) the fitted polygonprotected boolean optimize(georegression.struct.shapes.Polygon2D_F64 seed,
georegression.struct.shapes.Polygon2D_F64 current)
protected boolean optimize(georegression.struct.point.Point2D_F64 a,
georegression.struct.point.Point2D_F64 b,
georegression.struct.line.LineGeneral2D_F64 found)
a - Corner point in image coordinates.b - Corner point in image coordinates.found - (output) Line in image coordinatespublic SnapToEdge<T> getSnapToEdge()
public boolean isFitBlack()