Class RefinePolygonToGrayLine<T extends ImageGray<T>>
- All Implemented Interfaces:
RefinePolygonToGray<T>
Improves the fits of a polygon's which is darker or lighter than the background. Info'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 pixels (as is typical). Then the found lower and upper extends of the found polygon will also be 1,2 and 12,15.
If a line lies entirely along the image border it is not modified. If part of it lies along the image then only points not near the border are used to optimize its location.
For input polygons which are in undistorted coordinates by with a distorted image call getSnapToEdge()
and invoke BaseIntegralEdge.setTransform(PixelTransform<Point2D_F32>)
.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionRefinePolygonToGrayLine
(double cornerOffset, int lineSamples, int sampleRadius, int maxIterations, double convergeTolPixels, double maxCornerChangePixel, Class<T> imageType) Constructor which provides full access to all parameters.RefinePolygonToGrayLine
(int numSides, Class<T> imageType) Simplified constructor which uses reasonable default values for most variables -
Method Summary
Modifier and TypeMethodDescriptionvoid
Clears the previously set lens distortionprotected boolean
optimize
(Point2D_F64 a, Point2D_F64 b, LineGeneral2D_F64 found) Fits a line defined by the two points.protected boolean
optimize
(Polygon2D_F64 seed, Polygon2D_F64 current) Refines the initial line estimates using EM.boolean
refine
(Polygon2D_F64 input, Polygon2D_F64 output) Refines the fit a polygon by snapping it to the edges.void
Sets the image which is going to be processed.void
setLensDistortion
(int width, int height, @Nullable PixelTransform<Point2D_F32> distToUndist, @Nullable PixelTransform<Point2D_F32> undistToDist) Specifies lens distortionvoid
setTransform
(PixelTransform<Point2D_F32> undistToDist) Used to specify a transform that is applied to pixel coordinates to bring them back into original input image coordinates.
-
Field Details
-
image
-
-
Constructor Details
-
RefinePolygonToGrayLine
public RefinePolygonToGrayLine(double cornerOffset, int lineSamples, int sampleRadius, int maxIterations, double convergeTolPixels, double maxCornerChangePixel, Class<T> imageType) Constructor which provides full access to all parameters. See code documents value a description of these variables. -
RefinePolygonToGrayLine
Simplified constructor which uses reasonable default values for most variables- Parameters:
numSides
- Number of sides on the polygonimageType
- Type of input image it processes
-
-
Method Details
-
setImage
Sets the image which is going to be processed. If a transform is to be usedBaseIntegralEdge.setTransform(boofcv.struct.distort.PixelTransform<georegression.struct.point.Point2D_F32>)
should be called before this.- Specified by:
setImage
in interfaceRefinePolygonToGray<T extends ImageGray<T>>
-
setLensDistortion
public void setLensDistortion(int width, int height, @Nullable @Nullable PixelTransform<Point2D_F32> distToUndist, @Nullable @Nullable PixelTransform<Point2D_F32> undistToDist) Description copied from interface:RefinePolygonToGray
Specifies lens distortion- Specified by:
setLensDistortion
in interfaceRefinePolygonToGray<T extends ImageGray<T>>
-
clearLensDistortion
public void clearLensDistortion()Description copied from interface:RefinePolygonToGray
Clears the previously set lens distortion- Specified by:
clearLensDistortion
in interfaceRefinePolygonToGray<T extends ImageGray<T>>
-
refine
Refines the fit a polygon by snapping it to the edges.- Specified by:
refine
in interfaceRefinePolygonToGray<T extends ImageGray<T>>
- Parameters:
input
- (input) Initial estimate for the polygon. CW or CCW ordering doesn't matter.output
- (output) the fitted polygon- Returns:
- true if successful or false if it failed
-
optimize
Refines the initial line estimates using EM. The number of iterations is fixed. -
optimize
Fits a line defined by the two points. When fitting the line the weight of the edge is used to determine how influential the point is- Parameters:
a
- Corner point in image coordinates.b
- Corner point in image coordinates.found
- (output) Line in image coordinates- Returns:
- true if successful or false if it failed
-
setTransform
Used to specify a transform that is applied to pixel coordinates to bring them back into original input image coordinates. For example if the input image has lens distortion but the edge were found in undistorted coordinates this code needs to know how to go from undistorted back into distorted image coordinates in order to read the pixel's value.- Parameters:
undistToDist
- Pixel transformation from undistorted pixels into the actual distorted input image..
-
getSnapToEdge
-