Class AlgorithmHoughCircle

java.lang.Object
java.lang.Thread
gov.nih.mipav.model.algorithms.AlgorithmBase
gov.nih.mipav.model.algorithms.AlgorithmHoughCircle
All Implemented Interfaces:
ActionListener, WindowListener, Runnable, EventListener

public class AlgorithmHoughCircle extends AlgorithmBase
This Hough transform uses (xi, yi) points in the original image space to generate x0, y0, rad 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 x0 bins, y0 bins, rad bins, and number of circles. The default size for x0 is min(512, image.getExtents()[0]). The default size for y0 is min(512, image.getExtents()[1]). The default size for rad is min(512, max(image.getExtents()[0], image.getExtents()[1]). The default number of circles is 1. The program generates a Hough transform of the source image using the basic equation (x - x0)**2 + (y - y0)**2 = rad**2. The program finds the circles containing the largest number of points. The program produces a dialog which allows the user to select which circles should be drawn. The Hough transform for the entire image is generated a separate time to find each circle. For each (xi, yi) point in the original image not having a value of zero, calculate the first dimension value d1 = j * (xDim - 1)/(x0 - 1), with j = 0 to x0 - 1. Calculate the second dimension value d2 = k * (yDim - 1)/(y0 - 1), with k = 0 to y0 - 1. Calculate d3 = sqrt((x - d1)**2 + (y - d2)**2). d3 goes from 0 to maxRad = max(xDim-1, yDim-1)/2.0. s3 is the dimension 3 scaling factor. s3 * (rad - 1) = maxRad. s3 = maxRad/(rad - 1) m = d3*(rad - 1)/maxRad. Only calculate the Hough transform for d3 invalid input: '<'= maxRad. Find the peak point in the x0, y0, rad Hough transform space. Put the values for this peak point in x0Array[c], y0Array[c], radArray[c], and countArray[c]. If more circles are to be found, then zero the houghBuffer and run through the same Hough transform a second time, but on this second run instead of incrementing the Hough buffer, zero the values in the source buffer that contributed to the peak point in the Hough buffer. So on the next run of the Hough transform the source points that contributed to the Hough peak value just detected will not be present. Create a dialog with numCirclesFound x0Array[i], y0Array[i], radArray[i], and countArray[i] values, where the user will select a check box to have that circle drawn. 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 Details

    • x0

      private int x0
    • y0

      private int y0
    • rad

      private int rad
    • numCircles

      private int numCircles
    • testImage

      private ModelImage testImage
  • Constructor Details

    • AlgorithmHoughCircle

      public AlgorithmHoughCircle()
      AlgorithmHoughCircle - default constructor.
    • AlgorithmHoughCircle

      public AlgorithmHoughCircle(ModelImage destImg, ModelImage srcImg, int x0, int y0, int rad, int numCircles)
      AlgorithmHoughCircle.
      Parameters:
      destImg - Image with lines filled in
      srcImg - Binary source image that has lines with gaps
      x0 - number of dimension 1 bins in Hough transform space
      y0 - number of dimension 2 bins in Hough transform space
      rad - number of dimension 3 bins in Hough transform space
      numCircles - number of circles to be found
  • Method Details