Package com.xinapse.filter
Class MorphologicalOperator
java.lang.Object
com.xinapse.filter.AbstractKernelFilter
com.xinapse.filter.MorphologicalOperator
- All Implemented Interfaces:
SpatialFilter
A
SpatialFilter
for performing a morphological operation on an image.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
A FilterSpecifierPanel for a moprphological operation filter.static enum
An enumeration of the possible morphological operations on an image.Nested classes/interfaces inherited from interface com.xinapse.filter.SpatialFilter
SpatialFilter.SpecifierPanel
-
Field Summary
Modifier and TypeFieldDescriptionstatic final MorphologicalOperator
A 2-D dilate operator with a 3x3 kernel.static final MorphologicalOperator
A 3-D dilate operator with a 3x3x3 kernel.static final MorphologicalOperator
A 2-D erode operator with a 3x3 kernel.static final MorphologicalOperator
A 3-D erode operator with a 3x3x3 kernel.static final org.apache.commons.cli.Options
The Options for selecting a MorphologicalOperator.Fields inherited from interface com.xinapse.filter.SpatialFilter
N_DOTS
-
Constructor Summary
ConstructorDescriptionMorphologicalOperator
(boolean[][][] elt, MorphologicalOperator.Op op, BoundaryCondition boundaryCondition) Creates a new MorphologicalOperator with the given structuring element, operation and image boundary condition. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Tests whether the supplied argument is equal to this MorphologicalOperator.void
filterInPlace
(Object pixels, PixelDataType dataType, int nCols, int nRows, int nSlices, MonitorWorker worker, boolean verbose) Filter an array of pixel values "in place".void
filterInPlaceDouble
(double[] pixels, int nCols, int nRows, int nSlices, MonitorWorker worker, boolean verbose) Filter an array of double-precision pixel values "in place".void
filterInPlaceFloat
(float[] pixels, int nCols, int nRows, int nSlices, MonitorWorker worker, boolean verbose) Filter an array of floating-point pixel values "in place".static String
getName()
Returns the human-readable name of this filter.int
Returns the number of columns in the filter kernel.int
Returns the number of rows in the filter kernel.int
Returns the number of slices in the filter kernel.static String
Returns the name of this type of filter when specifying it in program optional arguments.static org.apache.commons.cli.Options
Returns the options for this type of filter.static SpatialFilter.SpecifierPanel
getSpecifierPanel
(String preferencesNodeName) Returns a SpatialFilter.SpecifierPanel that can be used to set the parameters for a MorphologicalOperator.int
hashCode()
static void
Runs a self-test of this class.static MorphologicalOperator
newCircular2DInstance
(int kernelSize, MorphologicalOperator.Op op, BoundaryCondition bc) Creates a new MorphologicalOperator with a 2-D circular kernel.static MorphologicalOperator
newCubic3DInstance
(int kernelSize, MorphologicalOperator.Op op, BoundaryCondition bc) Creates a new MorphologicalOperator with a 3-D cubic kernel.static MorphologicalOperator
newInstance
(org.apache.commons.cli.CommandLine commandLine, ReadableImage image) Creates a newMorphologicalOperator
using the supplied command line arguments.static MorphologicalOperator
newRectangular2DInstance
(int kernelSize, MorphologicalOperator.Op op, BoundaryCondition bc) Creates a new MorphologicalOperator with a 2-D rectangular kernel.static MorphologicalOperator
newSpherical3DInstance
(int kernelSize, MorphologicalOperator.Op op, BoundaryCondition bc) Creates a new MorphologicalOperator with a 3-D spherical kernel.toString()
Returns a String describing the operator.Methods inherited from class com.xinapse.filter.AbstractKernelFilter
filter, filter, filter, filterInPlace, filterInPlace, filterInPlace, filterInPlace, filterInPlace, filterInPlace, filterInPlaceBinary, filterInPlaceByte, filterInPlaceInt, filterInPlaceLong, filterInPlaceShort, filterInPlaceUByte, filterInPlaceUInt, filterInPlaceUShort
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.xinapse.filter.SpatialFilter
filter, filter, filterInPlace, filterInPlace, filterInPlace
-
Field Details
-
ERODE_2D_3_X_3
A 2-D erode operator with a 3x3 kernel. -
DILATE_2D_3_X_3
A 2-D dilate operator with a 3x3 kernel. -
ERODE_3D_3_X_3_X_3
A 3-D erode operator with a 3x3x3 kernel. -
DILATE_3D_3_X_3_X_3
A 3-D dilate operator with a 3x3x3 kernel. -
OPTIONS
public static final org.apache.commons.cli.Options OPTIONSThe Options for selecting a MorphologicalOperator.
-
-
Constructor Details
-
MorphologicalOperator
public MorphologicalOperator(boolean[][][] elt, MorphologicalOperator.Op op, BoundaryCondition boundaryCondition) throws IllegalArgumentException Creates a new MorphologicalOperator with the given structuring element, operation and image boundary condition.- Parameters:
elt
- a binary mask of the the structuring element.op
- the operation to perform.boundaryCondition
- how pixels at the edge of the image FoV should be treated.- Throws:
IllegalArgumentException
- if the kernel size is not odd in any of the dimensions.
-
-
Method Details
-
newInstance
public static MorphologicalOperator newInstance(org.apache.commons.cli.CommandLine commandLine, ReadableImage image) throws InvalidArgumentException Creates a newMorphologicalOperator
using the supplied command line arguments.- Parameters:
commandLine
- the command line from which a program is invoked.image
- the image to which this filter is designed to apply.- Returns:
- a new
MorphologicalOperator
. - Throws:
InvalidArgumentException
- if theMorphologicalOperator
cannot be created from the arguments.
-
newRectangular2DInstance
public static MorphologicalOperator newRectangular2DInstance(int kernelSize, MorphologicalOperator.Op op, BoundaryCondition bc) Creates a new MorphologicalOperator with a 2-D rectangular kernel.- Parameters:
kernelSize
- the kernel size.op
- the MorphologicalOperator.Op to perform.bc
- the image boundary condition to apply.- Returns:
- a new MorphologicalOperator with a 2-D rectangular kernel.
-
newCircular2DInstance
public static MorphologicalOperator newCircular2DInstance(int kernelSize, MorphologicalOperator.Op op, BoundaryCondition bc) Creates a new MorphologicalOperator with a 2-D circular kernel.- Parameters:
kernelSize
- the kernel size (diameter).op
- the MorphologicalOperator.Op to perform.bc
- the image boundary condition to apply.- Returns:
- a new MorphologicalOperator with a 2-D circular kernel.
-
newCubic3DInstance
public static MorphologicalOperator newCubic3DInstance(int kernelSize, MorphologicalOperator.Op op, BoundaryCondition bc) Creates a new MorphologicalOperator with a 3-D cubic kernel.- Parameters:
kernelSize
- the kernel size.op
- the MorphologicalOperator.Op to perform.bc
- the image boundary condition to apply.- Returns:
- a new MorphologicalOperator with a 3-D cubic kernel.
-
newSpherical3DInstance
public static MorphologicalOperator newSpherical3DInstance(int kernelSize, MorphologicalOperator.Op op, BoundaryCondition bc) Creates a new MorphologicalOperator with a 3-D spherical kernel.- Parameters:
kernelSize
- the kernel size (diameter).op
- the MorphologicalOperator.Op to perform.bc
- the image boundary condition to apply.- Returns:
- a new MorphologicalOperator with a 3-D spherical kernel.
-
getNKernelCols
public int getNKernelCols()Description copied from class:AbstractKernelFilter
Returns the number of columns in the filter kernel.- Specified by:
getNKernelCols
in classAbstractKernelFilter
- Returns:
- the number of columns in the filter kernel.
-
getNKernelRows
public int getNKernelRows()Description copied from class:AbstractKernelFilter
Returns the number of rows in the filter kernel.- Specified by:
getNKernelRows
in classAbstractKernelFilter
- Returns:
- the number of rows in the filter kernel.
-
getNKernelSlices
public int getNKernelSlices()Description copied from class:AbstractKernelFilter
Returns the number of slices in the filter kernel.- Specified by:
getNKernelSlices
in classAbstractKernelFilter
- Returns:
- the number of slices in the filter kernel.
-
filterInPlaceFloat
public void filterInPlaceFloat(float[] pixels, int nCols, int nRows, int nSlices, MonitorWorker worker, boolean verbose) throws CancelledException Description copied from class:AbstractKernelFilter
Filter an array of floating-point pixel values "in place".- Specified by:
filterInPlaceFloat
in classAbstractKernelFilter
- Parameters:
pixels
- the array of image pixel values.nCols
- the number of image columnsnRows
- the number of image rows.nSlices
- the number of image slices.worker
- the MonitorWorker that may be used to cancel the filter operation.verbose
- whether verbose reporting to System.out is turned on.- Throws:
CancelledException
- if the filter operation is cancelled by the user or programmatically.
-
filterInPlaceDouble
public void filterInPlaceDouble(double[] pixels, int nCols, int nRows, int nSlices, MonitorWorker worker, boolean verbose) throws CancelledException Description copied from class:AbstractKernelFilter
Filter an array of double-precision pixel values "in place". This default implementation should be overridden by SpatialFilters that are interested in a more efficient implementation for PixelDataType.DOUBLE images.- Overrides:
filterInPlaceDouble
in classAbstractKernelFilter
- Parameters:
pixels
- the array of image pixel values.nCols
- the number of image columnsnRows
- the number of image rows.nSlices
- the number of image slices.worker
- the MonitorWorker that may be used to cancel the filter operation.verbose
- whether verbose reporting to System.out is turned on.- Throws:
CancelledException
- if the filter operation is cancelled by the user or programmatically.
-
filterInPlace
public void filterInPlace(Object pixels, PixelDataType dataType, int nCols, int nRows, int nSlices, MonitorWorker worker, boolean verbose) throws CancelledException Description copied from interface:SpatialFilter
Filter an array of pixel values "in place".- Specified by:
filterInPlace
in interfaceSpatialFilter
- Overrides:
filterInPlace
in classAbstractKernelFilter
- Parameters:
pixels
- the array of image pixel values.dataType
- the PixelDataType of the pixels.nCols
- the number of image columns.nRows
- the number of image rows.nSlices
- the number of image slices.worker
- the MonitorWorker that may be used to cancel the filter operation.verbose
- whether verbose reporting to System.out is turned on.- Throws:
CancelledException
- if the filter operation is cancelled by the user or programmatically.
-
toString
Returns a String describing the operator. -
getOptionName
Returns the name of this type of filter when specifying it in program optional arguments.- Returns:
- the name of the filter for selection in program arguments.
-
getOptions
public static org.apache.commons.cli.Options getOptions()Returns the options for this type of filter.- Returns:
- the options for this type of filter.
-
getSpecifierPanel
Returns a SpatialFilter.SpecifierPanel that can be used to set the parameters for a MorphologicalOperator.- Parameters:
preferencesNodeName
- the preferences node name from which the initial settings will be taken.- Returns:
- a SpatialFilter.SpecifierPanel to set the parameters for this type of filter.
-
getName
Returns the human-readable name of this filter.- Returns:
- the human-readable name of this filter.
-
equals
Tests whether the supplied argument is equal to this MorphologicalOperator. -
hashCode
public int hashCode() -
main
Runs a self-test of this class.- Parameters:
args
- the program aguments (ignored).
-