Class AlgorithmHoughLine

  • All Implemented Interfaces:
    java.awt.event.ActionListener, java.awt.event.WindowListener, java.lang.Runnable, java.util.EventListener

    public class AlgorithmHoughLine
    extends AlgorithmBase
    This Hough transform uses (xi, yi) points in the original image space to generate rho, theta points in the Hough transform. This Hough transform module only works with binary images. Before it is used the user must compute the gradient of an image and threshold it to obtain a binary image. Noise removal and thinning should also be performed, if necessary, before this program is run. The user is asked for the number of rho and theta bins. The program generates a Hough transform of the source image using the basic equation rho = x*cos(theta) + y*sin(theta). The program selects the lines containing the largest number of points. The program can select up to maxLineNumber, which currently has a value of 10, lines. The program produces a dialog which allows the user to select which lines should be filled in and for selected lines the maximum length of the gaps to be filled. By setting the maximum distance equal to 0.0, the user can have this module function solely for line detection and not perform any line filling. rho goes from -sqrt((xDim-1)*(xDim-1) + (yDim-1)*(yDim-1)) to +sqrt((xDim-1)*(xDim-1) + (yDim-1)*(yDim-1)). theta goes from -PI/2 to +PI/2. rho has n1 cells and theta has n2 cells. d = sqrt((xDim-1)*(xDim-1) + (yDim-1)*(yDim-1)). For each (xi, yi) point in the original image not having a value of zero, calculate n2 values of theta. Take k from 0 to (n2 - 1) to generate theta(k) = -PI/2 + k*PI/n2. rho = x*cos(theta) + y*sin(theta). Then find which of n1 bins rho belongs to by calculating j = (rho + d)*n1/(2*d), with j going from 0 to n1-1. If j = n1, set j equal to n1 - 1. For each of the points in the Hough transform make a list of the x values and y values that went to generate it. Generate the Hough transform image. Find which rho, theta points are peak points in the rho, theta plane. Find up to maxLineNumber lines with the highest number of points by finding the peaks in the Hough transform with the highest number of counts. Note that only peaks in the rho, theta plane are considered so that we do not make selections from the spread around the peak. Form rho, theta, and count arrays for these lines. Create a dialog with numLinesFound rhoArray[i], thetaArray[i], and countArray[i] values, where the user will select a check box to have that line selected for gap filling and fill in a text field with the maximum gap length to be filled on that line. Fill in the gaps on the selected lines by examining distances between adjacent points. References: 1.) Digital Image Processing, Second Edition by Richard C. Gonzalez and Richard E. Woods, Section 10.2.2 Global Processing via the Hough Transform, Prentice-Hall, Inc., 2002, pp. 587-591. 2.) Shape Detection in Computer Vision Using the Hough Transform by V. F. Leavers, Springer-Verlag, 1992.
    • Field Detail

      • n1

        private int n1
      • n2

        private int n2
    • Constructor Detail

      • AlgorithmHoughLine

        public AlgorithmHoughLine()
        AlgorithmHoughLine - default constructor.
      • AlgorithmHoughLine

        public AlgorithmHoughLine​(ModelImage destImg,
                                  ModelImage srcImg,
                                  int n1,
                                  int n2)
        AlgorithmHoughLine.
        Parameters:
        destImg - Image with lines filled in
        srcImg - Binary source image that has lines with gaps
        n1 - number of rho bins
        n2 - number of theta bins