Package gov.nih.mipav.model.algorithms
Class AlgorithmGrayScaleMorphology3D
- java.lang.Object
-
- java.lang.Thread
-
- gov.nih.mipav.model.algorithms.AlgorithmBase
-
- gov.nih.mipav.model.algorithms.AlgorithmGrayScaleMorphology3D
-
- All Implemented Interfaces:
java.awt.event.ActionListener
,java.awt.event.WindowListener
,java.lang.Runnable
,java.util.EventListener
public class AlgorithmGrayScaleMorphology3D extends AlgorithmBase
Three-Dimensional mathematical morphology class applied to Gray scale images.- Version:
- 1.0 Aug 1999
- Author:
- Matthew J. McAuliffe, Ph.D.
-
-
Field Summary
Fields Modifier and Type Field Description private int
algorithm
algorithm type (i.e. erode, dilate)static int
BG_DISTANCE_MAP
DOCUMENT ME!static int
BOTTOM_HAT
static int
CLOSE
DOCUMENT ME!static int
CLOSING_BY_RECONSTRUCTION
static int
CONNECTED24
DOCUMENT ME!static int
CONNECTED26
static int
CONNECTED6
DOCUMENT ME!static int
DELETE_OBJECTS
DOCUMENT ME!static int
DILATE
DOCUMENT ME!static int
DISTANCE_MAP
DOCUMENT ME!static int
DISTANCE_MAP_FOR_SHAPE_INTERPOLATION
DOCUMENT ME!private int
edgingType
Edge type.private boolean
entireImage
if true, indicates that the VOIs should NOT be used and that entire image should be processed.static int
ERODE
DOCUMENT ME!static int
FILL_HOLES
DOCUMENT ME!static int
FIND_EDGES
DOCUMENT ME!static int
GEODESIC_DILATION
static int
GEODESIC_EROSION
private int
geodesicSize
Size of geodesic erosions and dilationsstatic int
ID_OBJECTS
DOCUMENT ME!private double[]
imgBuffer
imgBuffer that hold voxel value for the 3D slices.private double[]
imgBuffer2
static int
INNER_EDGING
Parameter used in Find_Edges.private int
iterationsD
Dilation iteration times.private int
iterationsE
Erosion iteration times.private int
kDimXY
Kernel dimension.private int
kDimZ
DOCUMENT ME!private java.util.BitSet
kernel
Kernel for both erosion and dilation.private int
kernelType
kernel size (i.e. connectedness)private double[]
maskBuffer
private ModelImage
maskImage
Used in geodesic dilation, geodesic erosion, morphological reconstruction by dilation, and morphological reconstruction by erosion Not used in opening by reconstruction and closing by reconstructionprivate int
max
maximum, minimum size of objects.private int
min
maximum, minimum size of objects.static int
MORPHOLOGICAL_GRADIENT
static int
MORPHOLOGICAL_LAPLACIAN
static int
MORPHOLOGICAL_RECONSTRUCTION_BY_DILATION
static int
MORPHOLOGICAL_RECONSTRUCTION_BY_EROSION
private int
numPruningPixels
Number pixels to prune.static int
OPEN
DOCUMENT ME!static int
OPENING_BY_RECONSTRUCTION
static int
OUTER_EDGING
Parameter used in Find_Edges.static int
PARTICLE_ANALYSIS
DOCUMENT ME!private float
pixDist
private double[]
processBuffer
intermediate processing buffer, same size with imgBuffer.static int
SIZED_SPHERE
DOCUMENT ME!static int
SKELETONIZE
DOCUMENT ME!private float
sphereDiameter
kernel diameter.static int
TOP_HAT
static int
ULTIMATE_ERODE
DOCUMENT ME!-
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 AlgorithmGrayScaleMorphology3D(ModelImage srcImg, int kernelType, float sphereDiameter, int method, int iterD, int iterE, int pruningPix, int edType, boolean entireImage)
Creates a new AlgorithmMorphology3D object.AlgorithmGrayScaleMorphology3D(ModelImage srcImg, ModelImage destImg, int kernelType, float sphereDiameter, int method, int iterD, int iterE, int pruningPix, int edType, boolean entireImage)
Creates a new AlgorithmMorphology3D object.AlgorithmGrayScaleMorphology3D(ModelImage srcImg, ModelImage destImg, ModelImage maskImage, int kernelType, float sphereDiameter, int method, int geodesicSize, int iterD, int iterE, boolean entireImage)
Creates a new AlgorithmGrayScaleMorphology3D object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
dilate(boolean returnFlag, int iters)
Dilates an image using the indicated kernel and the indicated number of iterations.private void
erode(boolean returnFlag, int iters)
Erodes an image using the indicated kernel and the indicated number of iterations.void
finalize()
Prepares this class for destruction.private void
geodesicDilation(boolean returnFlag, int geodesicSize)
geodesic dilation of a boolean, unsigned byte or unsigned short image using the indicated kernel and the indicated number of executions.private void
geodesicErosion(boolean returnFlag, int geodesicSize)
geodesic erosion of a boolean, unsigned byte or unsigned short image using the indicated kernel and the indicated number of executions.private void
makeKernel(int kernelType)
Generates a kernel of the indicated type.private void
makeSphericalKernel()
Generates a spherical kernel of a specific diameter.void
runAlgorithm()
Starts the program.void
setAlgorithm(int method)
Sets the algorithm type (i.e. erode, dilate)void
setImage(ModelImage img)
Sets new source image.void
setKernel(java.util.BitSet kernel, int dimXY, int dimZ)
Sets user defined square kernels.void
setMinMax(int _min, int _max)
Sets the bounds of object size used to delete objects.void
setPixDistance(float dist)
Used in the ultimate erode function to remove all eroded points less than the distance specified in pixel units.void
showKernel()
Display kernel as 1 or 0 in the debug window.-
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
-
ERODE
public static final int ERODE
DOCUMENT ME!- See Also:
- Constant Field Values
-
DILATE
public static final int DILATE
DOCUMENT ME!- See Also:
- Constant Field Values
-
CLOSE
public static final int CLOSE
DOCUMENT ME!- See Also:
- Constant Field Values
-
OPEN
public static final int OPEN
DOCUMENT ME!- See Also:
- Constant Field Values
-
ID_OBJECTS
public static final int ID_OBJECTS
DOCUMENT ME!- See Also:
- Constant Field Values
-
DELETE_OBJECTS
public static final int DELETE_OBJECTS
DOCUMENT ME!- See Also:
- Constant Field Values
-
DISTANCE_MAP
public static final int DISTANCE_MAP
DOCUMENT ME!- See Also:
- Constant Field Values
-
BG_DISTANCE_MAP
public static final int BG_DISTANCE_MAP
DOCUMENT ME!- See Also:
- Constant Field Values
-
ULTIMATE_ERODE
public static final int ULTIMATE_ERODE
DOCUMENT ME!- See Also:
- Constant Field Values
-
PARTICLE_ANALYSIS
public static final int PARTICLE_ANALYSIS
DOCUMENT ME!- See Also:
- Constant Field Values
-
SKELETONIZE
public static final int SKELETONIZE
DOCUMENT ME!- See Also:
- Constant Field Values
-
FIND_EDGES
public static final int FIND_EDGES
DOCUMENT ME!- See Also:
- Constant Field Values
-
FILL_HOLES
public static final int FILL_HOLES
DOCUMENT ME!- See Also:
- Constant Field Values
-
DISTANCE_MAP_FOR_SHAPE_INTERPOLATION
public static final int DISTANCE_MAP_FOR_SHAPE_INTERPOLATION
DOCUMENT ME!- See Also:
- Constant Field Values
-
MORPHOLOGICAL_GRADIENT
public static final int MORPHOLOGICAL_GRADIENT
- See Also:
- Constant Field Values
-
TOP_HAT
public static final int TOP_HAT
- See Also:
- Constant Field Values
-
BOTTOM_HAT
public static final int BOTTOM_HAT
- See Also:
- Constant Field Values
-
MORPHOLOGICAL_LAPLACIAN
public static final int MORPHOLOGICAL_LAPLACIAN
- See Also:
- Constant Field Values
-
GEODESIC_DILATION
public static final int GEODESIC_DILATION
- See Also:
- Constant Field Values
-
GEODESIC_EROSION
public static final int GEODESIC_EROSION
- See Also:
- Constant Field Values
-
MORPHOLOGICAL_RECONSTRUCTION_BY_DILATION
public static final int MORPHOLOGICAL_RECONSTRUCTION_BY_DILATION
- See Also:
- Constant Field Values
-
MORPHOLOGICAL_RECONSTRUCTION_BY_EROSION
public static final int MORPHOLOGICAL_RECONSTRUCTION_BY_EROSION
- See Also:
- Constant Field Values
-
OPENING_BY_RECONSTRUCTION
public static final int OPENING_BY_RECONSTRUCTION
- See Also:
- Constant Field Values
-
CLOSING_BY_RECONSTRUCTION
public static final int CLOSING_BY_RECONSTRUCTION
- See Also:
- Constant Field Values
-
SIZED_SPHERE
public static final int SIZED_SPHERE
DOCUMENT ME!- See Also:
- Constant Field Values
-
CONNECTED6
public static final int CONNECTED6
DOCUMENT ME!- See Also:
- Constant Field Values
-
CONNECTED24
public static final int CONNECTED24
DOCUMENT ME!- See Also:
- Constant Field Values
-
CONNECTED26
public static final int CONNECTED26
- See Also:
- Constant Field Values
-
OUTER_EDGING
public static final int OUTER_EDGING
Parameter used in Find_Edges. Indicates that the edge extracted is formed from the voxels that are directly adjacient to the ojbect.- See Also:
- Constant Field Values
-
INNER_EDGING
public static final int INNER_EDGING
Parameter used in Find_Edges. Indicates that the edge extracted is formed from the voxels that overlay the edge voxels of the object.- See Also:
- Constant Field Values
-
algorithm
private int algorithm
algorithm type (i.e. erode, dilate)
-
edgingType
private int edgingType
Edge type.
-
entireImage
private boolean entireImage
if true, indicates that the VOIs should NOT be used and that entire image should be processed.
-
imgBuffer
private double[] imgBuffer
imgBuffer that hold voxel value for the 3D slices.
-
imgBuffer2
private double[] imgBuffer2
-
maskBuffer
private double[] maskBuffer
-
iterationsD
private int iterationsD
Dilation iteration times.
-
iterationsE
private int iterationsE
Erosion iteration times.
-
kDimXY
private int kDimXY
Kernel dimension.
-
kDimZ
private int kDimZ
DOCUMENT ME!
-
kernel
private java.util.BitSet kernel
Kernel for both erosion and dilation.
-
kernelType
private int kernelType
kernel size (i.e. connectedness)
-
min
private int min
maximum, minimum size of objects.
-
max
private int max
maximum, minimum size of objects.
-
numPruningPixels
private int numPruningPixels
Number pixels to prune.
-
pixDist
private float pixDist
-
processBuffer
private double[] processBuffer
intermediate processing buffer, same size with imgBuffer.
-
sphereDiameter
private float sphereDiameter
kernel diameter.
-
maskImage
private ModelImage maskImage
Used in geodesic dilation, geodesic erosion, morphological reconstruction by dilation, and morphological reconstruction by erosion Not used in opening by reconstruction and closing by reconstruction
-
geodesicSize
private int geodesicSize
Size of geodesic erosions and dilations
-
-
Constructor Detail
-
AlgorithmGrayScaleMorphology3D
public AlgorithmGrayScaleMorphology3D(ModelImage srcImg, int kernelType, float sphereDiameter, int method, int iterD, int iterE, int pruningPix, int edType, boolean entireImage)
Creates a new AlgorithmMorphology3D object.- Parameters:
srcImg
- source image modelkernelType
- kernel size (i.e. connectedness)sphereDiameter
- only valid if kernelType == SIZED_SPHERE and represents the width of a circle in the resolution of the imagemethod
- setup the algorithm method (i.e. erode)iterD
- number of times to dilateiterE
- number of times to erodepruningPix
- the number of pixels to pruneedType
- the type of edging to perform (inner or outer)entireImage
- flag that indicates if the VOIs should NOT be used and entire image should be processed
-
AlgorithmGrayScaleMorphology3D
public AlgorithmGrayScaleMorphology3D(ModelImage srcImg, ModelImage destImg, int kernelType, float sphereDiameter, int method, int iterD, int iterE, int pruningPix, int edType, boolean entireImage)
Creates a new AlgorithmMorphology3D object.- Parameters:
srcImg
- source image modeldestImg
- destination image modelkernelType
- kernel size (i.e. connectedness)sphereDiameter
- only valid if kernelType == SIZED_SPHERE and represents the width of a circle in the resolution of the imagemethod
- setup the algorithm method (i.e. erode)iterD
- number of times to dilateiterE
- number of times to erodepruningPix
- the number of pixels to pruneedType
- the type of edging to perform (inner or outer)entireImage
- flag that indicates if the VOIs should NOT be used and entire image should be processed
-
AlgorithmGrayScaleMorphology3D
public AlgorithmGrayScaleMorphology3D(ModelImage srcImg, ModelImage destImg, ModelImage maskImage, int kernelType, float sphereDiameter, int method, int geodesicSize, int iterD, int iterE, boolean entireImage)
Creates a new AlgorithmGrayScaleMorphology3D object.- Parameters:
srcImg
- source image modelkernelType
- dilation kernel size (i.e. connectedness)sphereDiameter
- dilation only valid if kernelType == SIZED_SPHERE and represents the width of a circle in the resolution of the imagemethod
- setup the algorithm method (i.e. erode, dilate)geodesicSize
-iterD
- number of times to dilateiterE
- number of times to erodeentireImage
- if true, indicates that the VOIs should NOT be used and that entire image should be processed
-
-
Method Detail
-
finalize
public void finalize()
Prepares this class for destruction.- Overrides:
finalize
in classAlgorithmBase
-
runAlgorithm
public void runAlgorithm()
Starts the program.- Specified by:
runAlgorithm
in classAlgorithmBase
-
setAlgorithm
public void setAlgorithm(int method)
Sets the algorithm type (i.e. erode, dilate)- Parameters:
method
- algorithm type
-
setImage
public void setImage(ModelImage img)
Sets new source image.- Parameters:
img
- image model
-
setKernel
public void setKernel(java.util.BitSet kernel, int dimXY, int dimZ)
Sets user defined square kernels.- Parameters:
kernel
- user defined kerneldimXY
- length of x and y dimensionsdimZ
- length of z dimension
-
setMinMax
public void setMinMax(int _min, int _max)
Sets the bounds of object size used to delete objects.- Parameters:
_min
- minimum size of objects_max
- maximum size of objects
-
setPixDistance
public void setPixDistance(float dist)
Used in the ultimate erode function to remove all eroded points less than the distance specified in pixel units.- Parameters:
dist
- distance in pixels.
-
showKernel
public void showKernel()
Display kernel as 1 or 0 in the debug window.
-
dilate
private void dilate(boolean returnFlag, int iters)
Dilates an image using the indicated kernel and the indicated number of iterations. The grayscale dilation is the maximum value over the reflected kernel region. For symmetric kernels the reflected kernel is the same as the kernel.- Parameters:
returnFlag
- if true then this operation is a step in the morph process (i.e. close)iters
- number of dilation iterations
-
geodesicDilation
private void geodesicDilation(boolean returnFlag, int geodesicSize)
geodesic dilation of a boolean, unsigned byte or unsigned short image using the indicated kernel and the indicated number of executions.- Parameters:
returnFlag
- if true then this operation is a step in the morph process (i.e. close)geodesicSize
-
-
geodesicErosion
private void geodesicErosion(boolean returnFlag, int geodesicSize)
geodesic erosion of a boolean, unsigned byte or unsigned short image using the indicated kernel and the indicated number of executions.- Parameters:
returnFlag
- if true then this operation is a step in the morph process (i.e. close)geodesicSize
-
-
erode
private void erode(boolean returnFlag, int iters)
Erodes an image using the indicated kernel and the indicated number of iterations. The grayscale erosion is the minimum value over the kernel region.- Parameters:
returnFlag
- if true then this operation is a step in the morph process (i.e. open)iters
- number of erosion iterations
-
makeKernel
private void makeKernel(int kernelType)
Generates a kernel of the indicated type.- Parameters:
kernelType
- type of kernel to be generated.
-
makeSphericalKernel
private void makeSphericalKernel()
Generates a spherical kernel of a specific diameter. Most importantly it normalizes the kernel based on the resolution in the z-dimension. This in effect accounts for the anisotrophy in the z-dimension of typical 3D medical images. The resultant data is stored in the kernel class variable.
-
-