Class RefinePolygonLineToImage<T extends ImageGray>
- java.lang.Object
-
- boofcv.alg.shapes.polygon.RefinePolygonLineToImage<T>
-
- All Implemented Interfaces:
- RefineBinaryPolygon<T>
public class RefinePolygonLineToImage<T extends ImageGray> extends java.lang.Object implements RefineBinaryPolygon<T>
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 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 invokeBaseIntegralEdge.setTransform(PixelTransform_F32).
-
-
Constructor Summary
Constructors Constructor and Description RefinePolygonLineToImage(double cornerOffset, int lineSamples, int sampleRadius, int maxIterations, double convergeTolPixels, double maxCornerChangePixel, java.lang.Class<T> imageType)Constructor which provides full access to all parameters.RefinePolygonLineToImage(int numSides, java.lang.Class<T> imageType)Simplified constructor which uses reasonable default values for most variables
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description SnapToEdge<T>getSnapToEdge()booleanrefine(Polygon2D_F64 input, java.util.List<Point2D_I32> contour, GrowQueue_I32 splits, Polygon2D_F64 output)Refines the fit a polygon by snapping it to the edges.voidsetImage(T image)Sets the image which is going to be processed.voidsetLensDistortion(int width, int height, PixelTransform_F32 distToUndist, PixelTransform_F32 undistToDist)Specifies lens distortionvoidsetTransform(PixelTransform_F32 undistToDist)Used to specify a transform that is applied to pixel coordinates to bring them back into original input image coordinates.
-
-
-
Constructor Detail
-
RefinePolygonLineToImage
public RefinePolygonLineToImage(double cornerOffset, int lineSamples, int sampleRadius, int maxIterations, double convergeTolPixels, double maxCornerChangePixel, java.lang.Class<T> imageType)Constructor which provides full access to all parameters. See code documents value a description of these variables.
-
RefinePolygonLineToImage
public RefinePolygonLineToImage(int numSides, java.lang.Class<T> imageType)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 Detail
-
setImage
public void setImage(T image)
Sets the image which is going to be processed. If a transform is to be usedBaseIntegralEdge.setTransform(boofcv.struct.distort.PixelTransform_F32)should be called before this.- Specified by:
setImagein interfaceRefineBinaryPolygon<T extends ImageGray>
-
setLensDistortion
public void setLensDistortion(int width, int height, PixelTransform_F32 distToUndist, PixelTransform_F32 undistToDist)Description copied from interface:RefineBinaryPolygonSpecifies lens distortion- Specified by:
setLensDistortionin interfaceRefineBinaryPolygon<T extends ImageGray>
-
refine
public boolean refine(Polygon2D_F64 input, java.util.List<Point2D_I32> contour, GrowQueue_I32 splits, Polygon2D_F64 output)
Refines the fit a polygon by snapping it to the edges.- Specified by:
refinein interfaceRefineBinaryPolygon<T extends ImageGray>- Parameters:
input- (input) Initial estimate for the polygon. CW or CCW ordering doesn't matter.output- (output) the fitted polygoncontour- List of pixels in the contoursplits- Indexes in the contour where the initial polygon was found- Returns:
- true if successful or false if it failed
-
setTransform
public void setTransform(PixelTransform_F32 undistToDist)
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
public SnapToEdge<T> getSnapToEdge()
-
-
DataMelt 3.0 © DataMelt by jWork.ORG