A new release (2.1.0) of the LocalFilters
package is available. The API has been improved to make it clearer, more facilities (localmap
and localreduce
) are provided for local filtering operations, forward filtering is favoured (e.g. discrete correlation instead of discrete convolution) for faster computations.
Release notes:
-
New methods
localmap(f, A, B)
andlocalmap!(f, dst, A, B)
yield the result of applying the functionf
to the values ofA
taken in a neighborhood defined byB
around each position inA
forlocalmap
or indst
forlocalmap!
. -
Methods to locally reduce along given dimensions with an associative operator and using the van Herk-Gil-Werman algorithm have been renamed
localreduce
andlocalreduce!
. Callinglocalfilter
andlocalfilter!
for that purpose is deprecated. -
LocalFilters.ball(DimS{N}, r)
now yields a centeredN
-dimensional ball where values are set according to whether the distance to the center is≤ r
. Compared to the previous versions, add1//2
tor
to get a similar shape. The algorithm is faster and has been fixed forN > 2
. The result is identical whetherr
is integer or floating-point. -
In
localfilter!
, argumentinitial
may be a function to compute the state variable from the value of the source array at the current destination index. This imposes that the source and destination arrays have the same axes. This fixes issue#3. -
In
localfilter
, an optional first argument,T
, may be specified to provide the element type of the result. -
Morphological methods have a
slow
keyword (false
by default) to force not using the the van Herk-Gil-Werman algorithm. -
localmean
andlocalmean!
accept anull
keyword to specify the value of the result when the sum of weights in a neighborhood is zero. -
Macro
@public
to declare public methods even though they are not exported. This concept was introduced in Julia 1.11, for older Julia versions, nothing change. -
The algorithm to infer the result type is now based on Julia’s arithmetic rules and can cope with arguments that have units.
-
Non-exported public aliases
LocalFilters.Kernel{N}
andLocalFilters.Window{N}
for union of types suitable to defineN
-dimensional kernels or windows inLocalFilters
. A kernel is an array of weights implementing a local filter or an array of Booleans representing a local neighborhood. A window is an array of Booleans representing a local neighborhood. As an optimization, a box is an hyper-rectangular neighborhood with axes aligned with the Cartesian axes. Thus, a window whose values are all true is also a box and a kernel with Boolean values is also a window. The functionkernel(Dims{N},B)
yields anN
-dimensional array for anyB::LocalFilters.Kernel{N}
, with Boolean values for anyB::LocalFilters.Window{N}
. -
Non-exported public type
LocalFilters.Box{N}
is now an alias to an efficient type to representN
-dimensional boxes, that is uniformly true windows or hyper-rectangular neighborhoods. Currently, instances of this type are fast uniformly true arrays with offset axes from theStructuredArrays
package andLocalFilters.Box{N}
is justFastUniformArray{Bool,N,true}
. -
In local filtering operations, small integers arguments are automatically promoted to a wider integer type to avoid overflows. This is similar to what is done by base reduction methods such as
sum
andprod
. -
Exported method
B = reverse_kernel(args...)
yields a reversed kernel such that correlation byB
is identical to convolution byA = kernel(args...)
and conversely. -
Building a structuring element with
B = strel(T, args...)
acceptsargs...
likekernel
. -
Constants for filter ordering follow more general naming rules:
FORWARD_FILTER
andREVERSE_FILTER
instead ofForwardFilter
andReverseFilter
. -
Filter ordering is always specified by the keyword
order
and isFORWARD_FILTER
by default.