Package gov.nih.mipav.model.algorithms
Class AlgorithmHoughLine
- java.lang.Object
-
- java.lang.Thread
-
- gov.nih.mipav.model.algorithms.AlgorithmBase
-
- gov.nih.mipav.model.algorithms.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 Summary
Fields Modifier and Type Field Description private ModelImage
houghImage
private int
n1
private int
n2
private ModelImage
testImage
-
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 AlgorithmHoughLine()
AlgorithmHoughLine - default constructor.AlgorithmHoughLine(ModelImage destImg, ModelImage srcImg, int n1, int n2)
AlgorithmHoughLine.
-
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
-
n1
private int n1
-
n2
private int n2
-
houghImage
private ModelImage houghImage
-
testImage
private ModelImage testImage
-
-
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 insrcImg
- Binary source image that has lines with gapsn1
- number of rho binsn2
- number of theta bins
-
-
Method Detail
-
finalize
public void finalize()
finalize -- Overrides:
finalize
in classAlgorithmBase
-
runAlgorithm
public void runAlgorithm()
Starts the program.- Specified by:
runAlgorithm
in classAlgorithmBase
-
-