Class SnapToLineEdge<T extends ImageGray<T>>

java.lang.Object
boofcv.alg.shapes.edge.BaseIntegralEdge<T>
boofcv.alg.shapes.edge.SnapToLineEdge<T>

public class SnapToLineEdge<T extends ImageGray<T>>
extends BaseIntegralEdge<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 Details

    • lineSamples

      protected int lineSamples
    • radialSamples

      protected int radialSamples
    • weights

      protected DogArray_F64 weights
    • samplePts

      protected DogArray<Point2D_F64> samplePts
    • center

      protected Point2D_F64 center
    • localScale

      protected double localScale
  • Constructor Details

    • SnapToLineEdge

      public SnapToLineEdge​(int lineSamples, int tangentialSamples, Class<T> imageType)
      Configures the algorithm.
      Parameters:
      lineSamples - Number of times it will sample along the line's axis. Try 19
      tangentialSamples - 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

      public boolean refine​(Point2D_F64 a, Point2D_F64 b, LineGeneral2D_F64 found)
      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 line
      b - 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

      protected void localToGlobal​(LineGeneral2D_F64 line)
      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

      public Class<T> getImageType()
    • setImageType

      public void setImageType​(Class<T> imageType)