Package gov.nih.mipav.model.algorithms
Class AlgorithmAutoSeedWatershed
java.lang.Object
java.lang.Thread
gov.nih.mipav.model.algorithms.AlgorithmBase
gov.nih.mipav.model.algorithms.AlgorithmAutoSeedWatershed
- All Implemented Interfaces:
ActionListener,WindowListener,Runnable,EventListener
This is a port of the file AutoSeedWatershed.cpp which calls openCV written by Ravimal Bandara. His web site is
titled Image Segmentation using Unsupervised Watershed Algorithm with an Over-segmentation Reduction Technique.
This code is written for 2D color images. In response to the question:
Would it be possible to modify your code for use on black and white images? What changes would be necessary?
Ravimal Bandara responded:
Yes you can by creating a gray histogram instead of Hues Saturation histogram. But I am not sure about the accuracy
due to the grayscale histograms are less discriminative compared to the colour histogram.
His code is licensed under the Code Project Open License (CPOL).
The formula for the Bhattacharyya distance for multivariate gaussian distributions is taken from "The Divergence
and Bhattacharyya Distance Measures in Signal Selection" by Thomas Kailath, IEEE Transactions on Communication
Technology" Vol. COM-15, No. 1, February, 1967, pp. 52-60.
- Author:
- ilb
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ModelImageprivate booleanprivate ModelImageprivate doubleprivate booleanprivate floatprivate floatprivate intprivate ModelImageprivate ViewUserInterfaceFields inherited from class gov.nih.mipav.model.algorithms.AlgorithmBase
destFlag, destImage, image25D, mask, maxProgressValue, minProgressValue, multiThreadingEnabled, nthreads, progress, progressModulus, progressStep, runningInSeparateThread, separable, srcImage, threadStoppedFields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
ConstructorsConstructorDescriptionAlgorithmAutoSeedWatershed(ModelImage destImg, ModelImage srcImg, float scaleX, float scaleY, boolean mergeSimilar, double maxDistance) Constructs new watershed algorithm. -
Method Summary
Modifier and TypeMethodDescriptionvoidfinalize()Prepares this class for destruction.private voidvoidStarts the program.private voidMethods 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, windowOpenedMethods 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, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, suspend, threadId, toString, yield
-
Field Details
-
segmentNumber
private int segmentNumber -
grayImage
-
thresholdImage
-
distTransformed
-
scaleX
private float scaleX -
scaleY
private float scaleY -
mergeSimilar
private boolean mergeSimilar -
maxDistance
private double maxDistance -
error
private boolean error -
UI
-
-
Constructor Details
-
AlgorithmAutoSeedWatershed
public AlgorithmAutoSeedWatershed(ModelImage destImg, ModelImage srcImg, float scaleX, float scaleY, boolean mergeSimilar, double maxDistance) Constructs new watershed algorithm.- Parameters:
destImg- Image model where result image is to storedsrcImg- Source image modelscaleX-scaleY-mergeSimilar-maxDistance-
-
-
Method Details
-
finalize
public void finalize()Prepares this class for destruction.- Overrides:
finalizein classAlgorithmBase
-
runAlgorithm
public void runAlgorithm()Starts the program.- Specified by:
runAlgorithmin classAlgorithmBase
-
watershedSegment
private void watershedSegment() -
mergeSegments
private void mergeSegments()
-