Class HoughTransformBinary

java.lang.Object
boofcv.alg.feature.detect.line.HoughTransformBinary
Direct Known Subclasses:
HoughTransformBinary_MT

public class HoughTransformBinary extends Object

Hough transform which uses a polar line representation, distance from origin and angle (0 to 180 degrees). Standard implementation of a hough transform. 1) Gradient intensity image is used to find edge pixels. 2) All possible lines passing through that point are found. 3) Line parameters are summed up in the line image, in which each pixel represents a coordinate in parameter space. 3) Local maximums are found.

By the nature of this algorithms, lines are forced to be discretized into parameter space. The range can vary from +- the maximum range inside the image and the angle from 0 to PI radians. How finely discretized an image is effects line detection accuracy. If too fine lines might not be detected or it will be too noisy.

In the line image, the transform from line parameter coordinate to pixel coordinate is as follow:
x = r*cos(theta) + centerX
y = r*sin(theta) + centerY

USAGE NOTE: Duplicate/very similar lines are possible due to angles being cyclical. What happens is that if a line's orientation lies along a boundary point its angles will be split up between top and bottom of the transform. When lines are extracted using non-maximum it will detects peaks at the top and bottom.

  • Constructor Details

    • HoughTransformBinary

      public HoughTransformBinary(NonMaxSuppression extractor, HoughTransformParameters parameters)
      Specifies parameters of transform. The minimum number of points specified in the extractor is an important tuning parameter.
      Parameters:
      extractor - Extracts local maxima from transform space.
  • Method Details

    • transform

      public void transform(GrayU8 binary)
      Computes the Hough transform of the image.
      Parameters:
      binary - Binary image that indicates which pixels lie on edges.
    • extractLines

      protected void extractLines()
      Searches for local maximals and converts into lines.
    • mergeLines

      protected void mergeLines(int width, int height)
    • getTransform

      public GrayF32 getTransform()
      // * Returns the Hough transform image.
      Returns:
      Transform image.
    • getFoundIntensity

      public float[] getFoundIntensity()
      Returns the intensity/edge count for each returned line. Useful when doing post processing pruning.
      Returns:
      Array containing line intensities.
    • getLinesAll

      public DogArray<LineParametric2D_F32> getLinesAll()
    • getLinesMerged

      public List<LineParametric2D_F32> getLinesMerged()
    • getMergeAngle

      public double getMergeAngle()
    • setMergeAngle

      public void setMergeAngle(double mergeAngle)
    • getMergeDistance

      public double getMergeDistance()
    • setMergeDistance

      public void setMergeDistance(double mergeDistance)
    • getMaxLines

      public int getMaxLines()
    • setMaxLines

      public void setMaxLines(int maxLines)
    • getParameters

      public HoughTransformParameters getParameters()
    • setNumberOfCounts

      public void setNumberOfCounts(ConfigLength counts)