Package com.xinapse.filter
Class FixedWeightsComplexKernelFilter
java.lang.Object
com.xinapse.filter.AbstractComplexKernelFilter
com.xinapse.filter.FixedWeightsComplexKernelFilter
- All Implemented Interfaces:
SpatialFilter
public class FixedWeightsComplexKernelFilter
extends AbstractComplexKernelFilter
implements SpatialFilter
A class for performing filtering of complex images based on a moving kernel of pixels
with fixed complex weights within the kernel.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.xinapse.filter.SpatialFilter
SpatialFilter.SpecifierPanel
-
Field Summary
Modifier and TypeFieldDescriptionprotected final float[][][]
The 3-D array of weights in the kernel.Fields inherited from interface com.xinapse.filter.SpatialFilter
N_DOTS
-
Constructor Summary
ModifierConstructorDescriptionprotected
Default constructor produces an identityFixedWeightsComplexKernelFilter
with kernel size 1x1x1 that has no effect when applied.FixedWeightsComplexKernelFilter
(FloatComplex[][][] wts, boolean normalise, BoundaryCondition boundaryCondition) Constructs a 3-dimensional kernel-based filter with the given filter weights.FixedWeightsComplexKernelFilter
(FloatComplex[][] wts, boolean normalise, BoundaryCondition boundaryCondition) Constructs a 2-dimensional kernel-based filter with the given filter weights. -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(FixedWeightsComplexKernelFilter filter) Adds the weights from a FixedWeightsComplexKernelFilter to the weights of this one.add
(FixedWeightsComplexKernelFilter filter1, FixedWeightsComplexKernelFilter filter2) Adds the weights from two FixedWeightsComplexKernelFilters to create a new FixedWeightsComplexKernelFilter.Convolves this FixedWeightsComplexKernelFilter with another FixedWeightsComplexKernelFilter to create a new FixedWeightsComplexKernelFilter.copyResize
(int[] newSize, boolean normalise) Copies a FixedWeightsComplexKernelFilter, possibly resizing it, creating a new FixedWeightsComplexKernelFilter.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.void
scale
(float scaleFactor) Scale all kernel weights (both real and imaginary parts) by the given scaling factor.float
Returns the sum of the magnitude of all the weights for thisFixedWeightsComplexKernelFilter
.toString()
Returns aString
describing thisFixedWeightsComplexKernelFilter
.Methods inherited from class com.xinapse.filter.AbstractComplexKernelFilter
filter, filter, filter, filterInPlace, filterInPlace, filterInPlace, filterInPlace, filterInPlace, filterInPlace, filterInPlace
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.xinapse.filter.SpatialFilter
filter, filter, filterInPlace, filterInPlace, filterInPlace, filterInPlace
-
Field Details
-
complexWeights
protected final float[][][] complexWeightsThe 3-D array of weights in the kernel. The first index is the slice index, the second is the row index, and the third is the column index. Weights are in iterleaved real/imaginary pairs.
-
-
Constructor Details
-
FixedWeightsComplexKernelFilter
protected FixedWeightsComplexKernelFilter()Default constructor produces an identityFixedWeightsComplexKernelFilter
with kernel size 1x1x1 that has no effect when applied. -
FixedWeightsComplexKernelFilter
public FixedWeightsComplexKernelFilter(FloatComplex[][] wts, boolean normalise, BoundaryCondition boundaryCondition) throws IllegalArgumentException Constructs a 2-dimensional kernel-based filter with the given filter weights. The filter may optionally be normalised so that it is intensity-preserving (i.e., the sum of the magnitude of the weights will be forced to add up to 1).- Parameters:
wts
- a two-dimensional array of weights. This array must have an odd number of elements in each of the two dimensions. The centre of the weights kernel will be centred on the pixel being filtered. The first index of the array refers to the the row direction, and the second to the column direction.normalise
- iftrue
the weights will be normalised when constructing the kernel. If the weights cannot be normalised, then this argument has no effect.boundaryCondition
- theBoundaryCondition
to apply when this filter is applied to an array of pixels.- Throws:
IllegalArgumentException
- if the dimensions of the kernel weights array aren't odd-numbered in each of the two dimensions.
-
FixedWeightsComplexKernelFilter
public FixedWeightsComplexKernelFilter(FloatComplex[][][] wts, boolean normalise, BoundaryCondition boundaryCondition) throws IllegalArgumentException Constructs a 3-dimensional kernel-based filter with the given filter weights. The filter may optionally be normalised so that it is intensity-preserving (i.e., the sum of weights will be forced to add up to 1).- Parameters:
wts
- a three-dimensional array of weights. This array must have an odd number of elements in each of the three dimensions. The centre of the weights kernel will be centred on the pixel being filtered. The first index of the array refers to the slice direction, the second index to the row direction, and the third to the column direction.normalise
- iftrue
the weights will be normalised when constructing the kernel. If the weights cannot be normalised, then this argument has no effect.boundaryCondition
- theBoundaryCondition
to apply when this filter is applied to an array of pixels.- Throws:
IllegalArgumentException
- if the dimensions of the kernel weights array aren't odd-numbered in each of the three dimensions.
-
-
Method Details
-
getNKernelCols
public int getNKernelCols()Description copied from class:AbstractComplexKernelFilter
Returns the number of columns in the filter kernel.- Specified by:
getNKernelCols
in classAbstractComplexKernelFilter
- Returns:
- the number of columns in the filter kernel.
-
getNKernelRows
public int getNKernelRows()Description copied from class:AbstractComplexKernelFilter
Returns the number of rows in the filter kernel.- Specified by:
getNKernelRows
in classAbstractComplexKernelFilter
- Returns:
- the number of rows in the filter kernel.
-
getNKernelSlices
public int getNKernelSlices()Description copied from class:AbstractComplexKernelFilter
Returns the number of slices in the filter kernel.- Specified by:
getNKernelSlices
in classAbstractComplexKernelFilter
- Returns:
- the number of slices in the filter kernel.
-
scale
public void scale(float scaleFactor) Scale all kernel weights (both real and imaginary parts) by the given scaling factor.- Parameters:
scaleFactor
- the scaling factor for the weights.
-
sumWeights
public float sumWeights()Returns the sum of the magnitude of all the weights for thisFixedWeightsComplexKernelFilter
.- Returns:
- the sum magnitude of all the weights.
-
add
Adds the weights from a FixedWeightsComplexKernelFilter to the weights of this one.- Parameters:
filter
- the FixedWeightsComplexKernelFilter from which to add the weights.- Throws:
IllegalArgumentException
- if the two filters do not have the same kernel dimensions.
-
add
public static FixedWeightsComplexKernelFilter add(FixedWeightsComplexKernelFilter filter1, FixedWeightsComplexKernelFilter filter2) throws IllegalArgumentException Adds the weights from two FixedWeightsComplexKernelFilters to create a new FixedWeightsComplexKernelFilter.- Parameters:
filter1
- the first FixedWeightsComplexKernelFilter from which to add the weights.filter2
- the second FixedWeightsComplexKernelFilter from which to add the weights.- Returns:
- a new FixedWeightsComplexKernelFilter with weights which calculated by summing the weights from the two supplied filters.
- Throws:
IllegalArgumentException
- if the two filters do not have the same kernel dimensions.
-
copyResize
public FixedWeightsComplexKernelFilter copyResize(int[] newSize, boolean normalise) throws IllegalArgumentException Copies a FixedWeightsComplexKernelFilter, possibly resizing it, creating a new FixedWeightsComplexKernelFilter. If the requested size is larger than the current size in any direction, the new filter is padded with zeros. If the requested size is smaller than the current size in any direction, the new filter is cropped.- Parameters:
newSize
- an array of length at least 3 that specifies the new kernel size.normalise
- whether the resulting FixedWeightsComplexKernelFilter should be normalised (the sum of all weights should be unity).- Returns:
- a copy of the supplied FixedWeightsComplexKernelFilter, but resized.
- Throws:
IllegalArgumentException
-
convolve
Convolves this FixedWeightsComplexKernelFilter with another FixedWeightsComplexKernelFilter to create a new FixedWeightsComplexKernelFilter.- Parameters:
filter
- the FixedWeightsComplexKernelFilter with which this FixedWeightsComplexKernelFilter will be convolved.- Returns:
- a new FixedWeightsComplexKernelFilter that results from convolving this filter with the supplied filter.
-
toString
Returns aString
describing thisFixedWeightsComplexKernelFilter
.- Overrides:
toString
in classObject
- Returns:
- a
String
showing the weights of thisFixedWeightsComplexKernelFilter
.
-