Class AbstractKernelFilter
- All Implemented Interfaces:
SpatialFilter
- Direct Known Subclasses:
FixedWeightsKernelFilter, MedianFilter, MorphologicalOperator
SpatialFilter interface,
to minimize the effort required to implement this interface.
To implement a SpatialFilter, the programmer needs only to extend this class
and provide an implementation for the filterInPlaceFloat(float[], int, int, int, MonitorWorker, Logger),
getNKernelCols(),
getNKernelRows() and getNKernelSlices() methods.
Filtering of all other pixel data types will then be performed with this class's default
implementations for the other filtering methods. However, these methods are quite inefficient,
since they simply coerce the pixel values to float, perform the filtering operation using
filterInPlaceFloat(float[], int, int, int, MonitorWorker, Logger) method, and then
coerce the result back to the original data type. The programmer may therefore choose to
implement more efficient methods for the specific data types that they know this filter will
be used with. Furthermore, if the default implementations are used, filtering of
double-precision, integer and long data types may suffer from lack of precision.
-
Nested Class Summary
Nested classes/interfaces inherited from interface SpatialFilter
SpatialFilter.SpecifierPanel -
Field Summary
Fields inherited from interface SpatialFilter
FILTERING_STRING -
Method Summary
Modifier and TypeMethodDescriptionstatic WritableImagefilter(SpatialFilter filter, ReadableImage image, MonitorWorker worker, Logger logger) Filter a ReadableImage using the supplied filter, returning a new image which is a filtered version of the supplied image.filter(ReadableImage image, MonitorWorker worker, Logger logger) Filter a ReadableImage, returning a new image which is a filtered version of the supplied image.filter(ReadableImage image, Logger logger) Filter a ReadableImage, returning a new image which is a filtered version of the supplied image.static voidfilterInPlace(SpatialFilter filter, WritableImage image, MonitorWorker worker, Logger logger) Filter an image "in place".static voidfilterInPlace(SpatialFilter filter, WritableImage image, Logger logger) Filter a WritableImage "in place" using the supplied filter.static voidfilterInPlace(SpatialFilter filter, Object pixels, PixelDataType dataType, int nCols, int nRows, int nSlices, Logger logger) Filter an array of pixel values "in place".voidfilterInPlace(WritableImage image, MonitorWorker worker, Logger logger) Filter a WritableImage "in place".voidfilterInPlace(WritableImage image, Logger logger) Filter a WritableImage "in place".voidfilterInPlace(Object pixels, PixelDataType dataType, int nCols, int nRows, int nSlices, MonitorWorker worker, Logger logger) Filter an array of pixel values "in place".voidfilterInPlace(Object pixels, PixelDataType dataType, int nCols, int nRows, int nSlices, Logger logger) Filter an array of pixel values "in place".voidfilterInPlaceBinary(BitSet pixels, int nCols, int nRows, int nSlices, MonitorWorker worker, Logger logger) Filter an array of binary pixel values "in place".voidfilterInPlaceByte(byte[] pixels, int nCols, int nRows, int nSlices, MonitorWorker worker, Logger logger) Filter an array of signed byte pixel values "in place".voidfilterInPlaceDouble(double[] pixels, int nCols, int nRows, int nSlices, MonitorWorker worker, Logger logger) Filter an array of double-precision pixel values "in place".abstract voidfilterInPlaceFloat(float[] pixels, int nCols, int nRows, int nSlices, MonitorWorker worker, Logger logger) Filter an array of floating-point pixel values "in place".voidfilterInPlaceInt(int[] pixels, int nCols, int nRows, int nSlices, MonitorWorker worker, Logger logger) Filter an array of signed int pixel values "in place".voidfilterInPlaceLong(long[] pixels, int nCols, int nRows, int nSlices, MonitorWorker worker, Logger logger) Filter an array of long pixel values "in place".voidfilterInPlaceShort(short[] pixels, int nCols, int nRows, int nSlices, MonitorWorker worker, Logger logger) Filter an array of signed short pixel values "in place".voidfilterInPlaceUByte(byte[] pixels, int nCols, int nRows, int nSlices, MonitorWorker worker, Logger logger) Filter an array of unsigned byte pixel values "in place".voidfilterInPlaceUInt(int[] pixels, int nCols, int nRows, int nSlices, MonitorWorker worker, Logger logger) Filter an array of unsigned int pixel values "in place".voidfilterInPlaceUShort(short[] pixels, int nCols, int nRows, int nSlices, MonitorWorker worker, Logger logger) Filter an array of unsigned short pixel values "in place".abstract intReturns the number of columns in the filter kernel.abstract intReturns the number of rows in the filter kernel.abstract intReturns the number of slices in the filter kernel.
-
Method Details
-
filter
public WritableImage filter(ReadableImage image, Logger logger) throws InvalidImageException, IOException Description copied from interface:SpatialFilterFilter a ReadableImage, returning a new image which is a filtered version of the supplied image.- Specified by:
filterin interfaceSpatialFilter- Parameters:
image- the image to be filtered.logger- theLoggerfor verbose reporting and error messages.- Returns:
- a filtered version of the supplied image.
- Throws:
InvalidImageException- if the supplied image cannot be filtered with this filter.IOException- if an I/O error occurs.
-
filter
public WritableImage filter(ReadableImage image, MonitorWorker worker, Logger logger) throws InvalidImageException, IOException, CancelledException Description copied from interface:SpatialFilterFilter a ReadableImage, returning a new image which is a filtered version of the supplied image.- Specified by:
filterin interfaceSpatialFilter- Parameters:
image- the image to be filtered.worker- theMonitorWorkerthat may be used to cancel the filter operation.logger- theLoggerfor verbose reporting and error messages.- Returns:
- a filtered version of the supplied image.
- Throws:
InvalidImageException- if the supplied image cannot be filtered with this filter.IOException- if an I/O error occurs.CancelledException- if the filter operation is cancelled by the user or programmatically.
-
filterInPlace
public void filterInPlace(WritableImage image, Logger logger) throws InvalidImageException, IOException Description copied from interface:SpatialFilterFilter a WritableImage "in place".- Specified by:
filterInPlacein interfaceSpatialFilter- Parameters:
image- the image to be filtered.logger- theLoggerfor verbose reporting and error messages.- Throws:
InvalidImageException- if the supplied image cannot be filtered with this filter.IOException- if an I/O error occurs.
-
filterInPlace
public void filterInPlace(WritableImage image, MonitorWorker worker, Logger logger) throws InvalidImageException, IOException, CancelledException Description copied from interface:SpatialFilterFilter a WritableImage "in place".- Specified by:
filterInPlacein interfaceSpatialFilter- Parameters:
image- the image to be filtered.worker- theMonitorWorkerthat may be used to cancel the filter operation.logger- theLoggerfor verbose reporting and error messages.- Throws:
InvalidImageException- if the supplied image cannot be filtered with this filter.IOException- if an I/O error occurs.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, Logger logger) Description copied from interface:SpatialFilterFilter an array of pixel values "in place".- Specified by:
filterInPlacein interfaceSpatialFilter- 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.logger- theLoggerfor verbose reporting and error messages.
-
filterInPlace
public void filterInPlace(Object pixels, PixelDataType dataType, int nCols, int nRows, int nSlices, MonitorWorker worker, Logger logger) throws CancelledException Description copied from interface:SpatialFilterFilter an array of pixel values "in place".- Specified by:
filterInPlacein interfaceSpatialFilter- 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- theMonitorWorkerthat may be used to cancel the filter operation.logger- theLoggerfor verbose reporting and error messages.- Throws:
CancelledException- if the filter operation is cancelled by the user or programmatically.
-
filterInPlaceFloat
public abstract void filterInPlaceFloat(float[] pixels, int nCols, int nRows, int nSlices, MonitorWorker worker, Logger logger) throws CancelledException Filter an array of floating-point pixel values "in place".- 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.logger- theLoggerfor verbose reporting and error messages.- Throws:
CancelledException- if the filter operation is cancelled by the user or programmatically.
-
getNKernelCols
public abstract int getNKernelCols()Returns the number of columns in the filter kernel.- Returns:
- the number of columns in the filter kernel.
-
getNKernelRows
public abstract int getNKernelRows()Returns the number of rows in the filter kernel.- Returns:
- the number of rows in the filter kernel.
-
getNKernelSlices
public abstract int getNKernelSlices()Returns the number of slices in the filter kernel.- Returns:
- the number of slices in the filter kernel.
-
filterInPlaceBinary
public void filterInPlaceBinary(BitSet pixels, int nCols, int nRows, int nSlices, MonitorWorker worker, Logger logger) throws CancelledException Filter an array of binary pixel values "in place". This default implementation should be overridden by AbstractKernelFilters that are interested in a more efficient implementation for PixelDataType.BINARY images.- 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.logger- theLoggerfor verbose reporting and error messages.- Throws:
CancelledException- if the filter operation is cancelled by the user or programmatically.
-
filterInPlaceByte
public void filterInPlaceByte(byte[] pixels, int nCols, int nRows, int nSlices, MonitorWorker worker, Logger logger) throws CancelledException Filter an array of signed byte pixel values "in place". This default implementation should be overridden by SpatialFilters that are interested in a more efficient implementation for PixelDataType.BYTE images.- 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.logger- theLoggerfor verbose reporting and error messages.- Throws:
CancelledException- if the filter operation is cancelled by the user or programmatically.
-
filterInPlaceUByte
public void filterInPlaceUByte(byte[] pixels, int nCols, int nRows, int nSlices, MonitorWorker worker, Logger logger) throws CancelledException Filter an array of unsigned byte pixel values "in place". This default implementation should be overridden by SpatialFilters that are interested in a more efficient implementation for PixelDataType.UBYTE images.- 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.logger- theLoggerfor verbose reporting and error messages.- Throws:
CancelledException- if the filter operation is cancelled by the user or programmatically.
-
filterInPlaceShort
public void filterInPlaceShort(short[] pixels, int nCols, int nRows, int nSlices, MonitorWorker worker, Logger logger) throws CancelledException Filter an array of signed short pixel values "in place". This default implementation should be overridden by SpatialFilters that are interested in a more efficient implementation for PixelDataType.SHORT images.- 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.logger- theLoggerfor verbose reporting and error messages.- Throws:
CancelledException- if the filter operation is cancelled by the user or programmatically.
-
filterInPlaceUShort
public void filterInPlaceUShort(short[] pixels, int nCols, int nRows, int nSlices, MonitorWorker worker, Logger logger) throws CancelledException Filter an array of unsigned short pixel values "in place". This default implementation should be overridden by SpatialFilters that are interested in a more efficient implementation for PixelDataType.USHORT images.- 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.logger- theLoggerfor verbose reporting and error messages.- Throws:
CancelledException- if the filter operation is cancelled by the user or programmatically.
-
filterInPlaceInt
public void filterInPlaceInt(int[] pixels, int nCols, int nRows, int nSlices, MonitorWorker worker, Logger logger) throws CancelledException Filter an array of signed int pixel values "in place". This default implementation should be overridden by SpatialFilters that are interested in a more efficient implementation for PixelDataType.INT images.- 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.logger- theLoggerfor verbose reporting and error messages.- Throws:
CancelledException- if the filter operation is cancelled by the user or programmatically.
-
filterInPlaceUInt
public void filterInPlaceUInt(int[] pixels, int nCols, int nRows, int nSlices, MonitorWorker worker, Logger logger) throws CancelledException Filter an array of unsigned int pixel values "in place". This default implementation should be overridden by SpatialFilters that are interested in a more efficient implementation for PixelDataType.UINT images.- 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.logger- theLoggerfor verbose reporting and error messages.- Throws:
CancelledException- if the filter operation is cancelled by the user or programmatically.
-
filterInPlaceLong
public void filterInPlaceLong(long[] pixels, int nCols, int nRows, int nSlices, MonitorWorker worker, Logger logger) throws CancelledException Filter an array of long pixel values "in place". This default implementation should be overridden by SpatialFilters that are interested in a more efficient implementation for PixelDataType.LONG images.- 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.logger- theLoggerfor verbose reporting and error messages.- 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, Logger logger) throws CancelledException 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.- 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.logger- theLoggerfor verbose reporting and error messages.- Throws:
CancelledException- if the filter operation is cancelled by the user or programmatically.
-
filter
public static WritableImage filter(SpatialFilter filter, ReadableImage image, MonitorWorker worker, Logger logger) throws InvalidImageException, CancelledException Filter a ReadableImage using the supplied filter, returning a new image which is a filtered version of the supplied image.- Parameters:
filter- the filter to be applied.image- the image to be filtered.worker- the MonitorWorker that may be used to cancel the filter operation.logger- theLoggerfor verbose reporting and error messages.- Returns:
- a new image which is a filtered version of the supplied image.
- Throws:
InvalidImageException- if the supplied image cannot be filtered with the filter.CancelledException- if the filter operation is cancelled by the user or programmatically.
-
filterInPlace
public static void filterInPlace(SpatialFilter filter, WritableImage image, Logger logger) throws InvalidImageException Filter a WritableImage "in place" using the supplied filter.- Parameters:
filter- the filter to be applied.image- the image to be filtered.logger- theLoggerfor verbose reporting and error messages.- Throws:
InvalidImageException- if the supplied image cannot be filtered with the filter.
-
filterInPlace
public static void filterInPlace(SpatialFilter filter, Object pixels, PixelDataType dataType, int nCols, int nRows, int nSlices, Logger logger) Filter an array of pixel values "in place".- Parameters:
filter- the filter to be applied.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.logger- theLoggerfor verbose reporting and error messages.
-
filterInPlace
public static void filterInPlace(SpatialFilter filter, WritableImage image, MonitorWorker worker, Logger logger) throws InvalidImageException, CancelledException Filter an image "in place".- Parameters:
filter- the filter to be applied.image- the image to be filtered.worker- the MonitorWorker that may be used to cancel the filter operation.logger- theLoggerfor verbose reporting and error messages.- Throws:
InvalidImageException- if the supplied image cannot be filtered with the filter.CancelledException- if the filter operation is cancelled by the user or programmatically.
-