Package gov.nih.mipav.model.algorithms
Class AlgorithmHoughCircle
- java.lang.Object
-
- java.lang.Thread
-
- gov.nih.mipav.model.algorithms.AlgorithmBase
-
- gov.nih.mipav.model.algorithms.AlgorithmHoughCircle
-
- All Implemented Interfaces:
java.awt.event.ActionListener
,java.awt.event.WindowListener
,java.lang.Runnable
,java.util.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 <= 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 Summary
Fields Modifier and Type Field Description private int
numCircles
private int
rad
private ModelImage
testImage
private int
x0
private int
y0
-
Fields inherited from class gov.nih.mipav.model.algorithms.AlgorithmBase
destFlag, destImage, image25D, mask, maxProgressValue, minProgressValue, multiThreadingEnabled, nthreads, progress, progressModulus, progressStep, runningInSeparateThread, separable, srcImage, threadStopped
-
-
Constructor Summary
Constructors Constructor Description AlgorithmHoughCircle()
AlgorithmHoughCircle - default constructor.AlgorithmHoughCircle(ModelImage destImg, ModelImage srcImg, int x0, int y0, int rad, int numCircles)
AlgorithmHoughCircle.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
finalize()
finalize -void
runAlgorithm()
Starts the program.-
Methods inherited from class gov.nih.mipav.model.algorithms.AlgorithmBase
actionPerformed, addListener, addProgressChangeListener, calculateImageSize, calculatePrincipleAxis, computeElapsedTime, computeElapsedTime, convertIntoFloat, delinkProgressToAlgorithm, delinkProgressToAlgorithmMulti, displayError, errorCleanUp, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, generateProgressValues, getDestImage, getElapsedTime, getMask, getMaxProgressValue, getMinProgressValue, getNumberOfThreads, getProgress, getProgressChangeListener, getProgressChangeListeners, getProgressModulus, getProgressStep, getProgressValues, getSrcImage, isCompleted, isImage25D, isMultiThreadingEnabled, isRunningInSeparateThread, isThreadStopped, linkProgressToAlgorithm, linkProgressToAlgorithm, makeProgress, notifyListeners, removeListener, removeProgressChangeListener, run, setCompleted, setImage25D, setMask, setMaxProgressValue, setMinProgressValue, setMultiThreadingEnabled, setNumberOfThreads, setProgress, setProgressModulus, setProgressStep, setProgressValues, setProgressValues, setRunningInSeparateThread, setSrcImage, setStartTime, setThreadStopped, startMethod, windowActivated, windowClosed, windowClosing, windowDeactivated, windowDeiconified, windowIconified, windowOpened
-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
-
-
-
Field Detail
-
x0
private int x0
-
y0
private int y0
-
rad
private int rad
-
numCircles
private int numCircles
-
testImage
private ModelImage testImage
-
-
Constructor Detail
-
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 insrcImg
- Binary source image that has lines with gapsx0
- number of dimension 1 bins in Hough transform spacey0
- number of dimension 2 bins in Hough transform spacerad
- number of dimension 3 bins in Hough transform spacenumCircles
- number of circles to be found
-
-
Method Detail
-
finalize
public void finalize()
finalize -- Overrides:
finalize
in classAlgorithmBase
-
runAlgorithm
public void runAlgorithm()
Starts the program.- Specified by:
runAlgorithm
in classAlgorithmBase
-
-