72
72
"""
73
73
localreduce(op, [T=eltype(A),] A, dims, rngs; kwds...) -> dst
74
74
75
- yields the result of applying van Herk-Gil-Werman algorithm to filter array `A` along
76
- dimension(s) `dims` with associative binary operator `op` and contiguous structuring
77
- element(s) defined by the interval(s) `rngs`.
75
+ yields the local reduction by the associative binary operator `op` of the values of `A`
76
+ into contiguous hyper-rectangular neighborhoods defined by the interval(s) `rngs` along
77
+ dimension(s) `dims` of `A`. The algorithm of van Herk-Gil-Werman is used to compute the
78
+ reduction.
78
79
79
80
Optional argument `T` is to specify the element type of the result.
80
81
81
- Argument `dims` specifies along which dimension(s) of `A` the filter is to be applied, it
82
- can be a single integer, a tuple of integers, or a colon `:` to apply the operation to all
83
- dimensions. Dimensions are processed in the order given by `dims` (the same dimension may
84
- appear several times) and there must be a matching interval in `rngs` to specify the
85
- structuring element (except that, if `rngs` is a single interval, it is used for every
86
- dimension in `dims`). An interval is either an integer or an integer valued unit range in
87
- the form `kmin:kmax`. An interval specified as a single integer yields an approximately
88
- centered range of this length.
82
+ Argument `dims` specifies along which dimension(s) of `A` the local reduction is to be
83
+ applied, it can be a single integer, a tuple of integers, or a colon `:` to apply the
84
+ operation to all dimensions. Dimensions are processed in the order given by `dims` (the
85
+ same dimension may appear several times) and there must be a matching interval in `rngs`
86
+ to specify the structuring element (except that, if `rngs` is a single interval, it is
87
+ used for every dimension in `dims`). An interval is either an integer or an integer valued
88
+ unit range in the form `kmin:kmax`. An interval specified as a single integer is treated
89
+ as an approximately centered range of this length.
89
90
90
91
Keyword `order` specifies the filter direction, `FORWARD_FILTER` by default.
91
92
@@ -114,6 +115,10 @@ element of width 7 in every dimension can be obtained by:
114
115
115
116
localreduce(min, A, :, -3:3)
116
117
118
+ or equivalently by:
119
+
120
+ localreduce(min, A, :, 7)
121
+
117
122
Index interval `0:0` may be specified to do nothing along the corresponding dimension. For
118
123
instance, assuming `A` is a three-dimensional array:
119
124
@@ -127,10 +132,10 @@ may be obtained with:
127
132
128
133
where the second dimension is omitted from the list of dimensions.
129
134
130
- The *local average* of the two-dimensional array `A` on a centered moving window of size
135
+ The *local average* of the two-dimensional array `A` on a centered sliding window of size
131
136
11×11 can be computed as:
132
137
133
- localreduce(+, A, :, (-5:5, -5:5)) ./ 11
138
+ localreduce(+, A, :, (-5:5, -5:5)) ./ 11^2
134
139
135
140
See [`localreduce!`](@ref) for an in-place version of the method.
136
141
@@ -144,13 +149,13 @@ localreduce(op, ::Type{T}, A::AbstractArray, dims::Dimensions, rngs::Ranges; kwd
144
149
"""
145
150
localreduce!(op, [dst = A,] A, dims, rngs; kwds...)
146
151
147
- overwrites the contents of `dst` with the result of applying van Herk-Gil-Werman algorithm
148
- to locally reduce array `A` along dimension(s) `dims` with associative binary operator
149
- `op` and contiguous structuring element (s) defined by the interval (s) `rngs` . Except if a
150
- single dimension of interest is specified by `dims`, the destination `dst` must have the
151
- same indices as the source `A` (that is, `axes(dst) == axes(A)`). Operation may be done
152
- in-place and `dst` and ` A` can be the same; this is the default behavior if `dst` is not
153
- specified .
152
+ overwrites the contents of `dst` with the local reduction by the associative binary
153
+ operator `op` of the values of `A` into contiguous hyper-rectangular neighborhoods defined
154
+ by the interval (s) `rngs` along dimension (s) `dims` of `A` . Except if a single dimension
155
+ of interest is specified by `dims`, the destination `dst` must have the same indices as
156
+ the source `A` (that is, `axes(dst) == axes(A)`). Operation may be done in-place and `dst`
157
+ and `A` can be the same; this is the default behavior if `dst` is not specified. The
158
+ algorithm of van Herk-Gil-Werman is used to compute the reduction .
154
159
155
160
See [`localreduce`](@ref) for a full description of the method and for accepted keywords.
156
161
0 commit comments