Class SnapToLineEdge<T extends ImageGray<T>>
Snaps a line to an edge of an object. The refined line attempts to maximize the absolute value of the difference between the left and right sides of the line.
The algorithm works by sampling along the provided line segment. For each point along the line it also samples points tangential to it in the left and right direction. When a point is sampled it is actually the line integral between two points which are one pixel apart. The weight is found as the absolute value of difference the between two adjacent line integrals along the tangent.
Internally it will compute the solution in a local coordinate system to reduce numerical errors.
DISTORTED INPUT IMAGE: If the distortion is known it is possible to sample along a straight line in distorted
image space. This can be accomplished through the use of BaseIntegralEdge.setTransform(boofcv.struct.distort.PixelTransform<georegression.struct.point.Point2D_F32>)
where the provided transform
goes from undistorted pixel coordinates into the distorted input image.
-
Field Summary
Modifier and TypeFieldDescriptionprotected Point2D_F64
protected int
protected double
protected int
protected DogArray<Point2D_F64>
protected DogArray_F64
Fields inherited from class boofcv.alg.shapes.edge.BaseIntegralEdge
integral, integralImage
-
Constructor Summary
ConstructorDescriptionSnapToLineEdge
(int lineSamples, int tangentialSamples, Class<T> imageType) Configures the algorithm. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
computePointsAndWeights
(double slopeX, double slopeY, double x0, double y0, double tanX, double tanY) Computes the location of points along the line and their weightsint
int
protected void
Converts the line from local to global image coordinatesboolean
refine
(Point2D_F64 a, Point2D_F64 b, LineGeneral2D_F64 found) Fits a line defined by the two points.void
setImageType
(Class<T> imageType) void
setLineSamples
(int lineSamples) void
setRadialSamples
(int radialSamples) Methods inherited from class boofcv.alg.shapes.edge.BaseIntegralEdge
getInputType, setImage, setTransform
-
Field Details
-
lineSamples
protected int lineSamples -
radialSamples
protected int radialSamples -
weights
-
samplePts
-
center
-
localScale
protected double localScale
-
-
Constructor Details
-
SnapToLineEdge
Configures the algorithm.- Parameters:
lineSamples
- Number of times it will sample along the line's axis. Try 19tangentialSamples
- Radius along the tangent of what it will sample. Must be ≥ 1. Try 2.imageType
- Type of image it's going to process
-
-
Method Details
-
refine
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. Multiple calls might be required to get a perfect fit.- Parameters:
a
- Start of lineb
- End of line..found
- (output) Fitted line to the edge- Returns:
- true if successful or false if it failed
-
computePointsAndWeights
protected void computePointsAndWeights(double slopeX, double slopeY, double x0, double y0, double tanX, double tanY) Computes the location of points along the line and their weights -
localToGlobal
Converts the line from local to global image coordinates -
getLineSamples
public int getLineSamples() -
setLineSamples
public void setLineSamples(int lineSamples) -
getRadialSamples
public int getRadialSamples() -
setRadialSamples
public void setRadialSamples(int radialSamples) -
getImageType
-
setImageType
-