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
Nested ClassesModifier and TypeClassDescriptionstatic classA FilterSpecifierPanel for a moprphological operation filter.static enumAn enumeration of the possible morphological operations on an image.Nested classes/interfaces inherited from interface com.xinapse.filter.SpatialFilter
SpatialFilter.SpecifierPanel -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final MorphologicalOperatorA 2-D dilate operator with a 3x3 kernel.static final MorphologicalOperatorA 3-D dilate operator with a 3x3x3 kernel.static final MorphologicalOperatorA 2-D erode operator with a 3x3 kernel.static final MorphologicalOperatorA 3-D erode operator with a 3x3x3 kernel.static final org.apache.commons.cli.OptionsThe Options for selecting a MorphologicalOperator.Fields inherited from interface com.xinapse.filter.SpatialFilter
N_DOTS -
Constructor Summary
ConstructorsConstructorDescriptionMorphologicalOperator(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 TypeMethodDescriptionbooleanTests whether the supplied argument is equal to this MorphologicalOperator.voidfilterInPlace(Object pixels, PixelDataType dataType, int nCols, int nRows, int nSlices, MonitorWorker worker, boolean verbose) Filter an array of pixel values "in place".voidfilterInPlaceDouble(double[] pixels, int nCols, int nRows, int nSlices, MonitorWorker worker, boolean verbose) Filter an array of double-precision pixel values "in place".voidfilterInPlaceFloat(float[] pixels, int nCols, int nRows, int nSlices, MonitorWorker worker, boolean verbose) Filter an array of floating-point pixel values "in place".static StringgetName()Returns the human-readable name of this filter.intReturns the number of columns in the filter kernel.intReturns the number of rows in the filter kernel.intReturns the number of slices in the filter kernel.static StringReturns the name of this type of filter when specifying it in program optional arguments.static org.apache.commons.cli.OptionsReturns the options for this type of filter.static SpatialFilter.SpecifierPanelgetSpecifierPanel(String preferencesNodeName) Returns a SpatialFilter.SpecifierPanel that can be used to set the parameters for a MorphologicalOperator.inthashCode()static voidRuns a self-test of this class.static MorphologicalOperatornewCircular2DInstance(int kernelSize, MorphologicalOperator.Op op, BoundaryCondition bc) Creates a new MorphologicalOperator with a 2-D circular kernel.static MorphologicalOperatornewCubic3DInstance(int kernelSize, MorphologicalOperator.Op op, BoundaryCondition bc) Creates a new MorphologicalOperator with a 3-D cubic kernel.static MorphologicalOperatornewInstance(org.apache.commons.cli.CommandLine commandLine, ReadableImage image) Creates a newMorphologicalOperatorusing the supplied command line arguments.static MorphologicalOperatornewRectangular2DInstance(int kernelSize, MorphologicalOperator.Op op, BoundaryCondition bc) Creates a new MorphologicalOperator with a 2-D rectangular kernel.static MorphologicalOperatornewSpherical3DInstance(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, filterInPlaceUShortMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods 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 newMorphologicalOperatorusing 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 theMorphologicalOperatorcannot 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:AbstractKernelFilterReturns the number of columns in the filter kernel.- Specified by:
getNKernelColsin classAbstractKernelFilter- Returns:
- the number of columns in the filter kernel.
-
getNKernelRows
public int getNKernelRows()Description copied from class:AbstractKernelFilterReturns the number of rows in the filter kernel.- Specified by:
getNKernelRowsin classAbstractKernelFilter- Returns:
- the number of rows in the filter kernel.
-
getNKernelSlices
public int getNKernelSlices()Description copied from class:AbstractKernelFilterReturns the number of slices in the filter kernel.- Specified by:
getNKernelSlicesin 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:AbstractKernelFilterFilter an array of floating-point pixel values "in place".- Specified by:
filterInPlaceFloatin 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:AbstractKernelFilterFilter 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:
filterInPlaceDoublein 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:SpatialFilterFilter an array of pixel values "in place".- Specified by:
filterInPlacein interfaceSpatialFilter- Overrides:
filterInPlacein 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).
-