You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
filters an array by multiplication in Fourierspace. This version uses in-place Fourier-transforms and multiplication whereever possible.
8
+
The filter window function is assumed to be separable. Depending on the array type either full-complex or real-to-complex FFTs will be used.
9
+
Note that some array types cannot directly be processed due to the type inference mechanism, in which case you should transform such types to
10
+
a standard array type (usually via calling "collect").
11
+
High-pass filters can be used by exchanging the border_in and border_out argument values.
12
+
13
+
#Arguments
14
+
+`arr`: the array to filter
15
+
+`fct`: the separable window function to use. The function has an ND-array size as the first parameter but wil be called with only one non-singleton dimension at a time.
16
+
+`kwargs...`: keyword arguments which will be passed to fct. These typically are `border_in=0.8` and `border_out=1.0` for the window-functions as defined in the `IndexFunArrays.jl` toolbox.
filters an array by multiplication in Fourierspace. This version uses in-place Fourier-transforms and multiplication whereever possible.
60
+
The filter window function is assumed to be separable. Depending on the array type either full-complex or real-to-complex FFTs will be used.
61
+
Note that some array types cannot directly be processed due to the type inference mechanism, in which case you should transform such types to
62
+
a standard array type (usually via calling "collect").
63
+
High-pass filters can be used by exchanging the border_in and border_out argument values.
64
+
65
+
#Arguments
66
+
+`arr`: the array to filter
67
+
+`fct`: the separable window function to use. The function has an ND-array size as the first parameter but wil be called with only one non-singleton dimension at a time.
68
+
+`kwargs...`: keyword arguments which will be passed to fct. These typically are `border_in=0.8` and `border_out=1.0` for the window-functions as defined in the `IndexFunArrays.jl` toolbox.
functionfourier_filter_by_1D_FT!(arr::TA, fct=window_gaussian; border_in=0.0, border_out=1.0, dims=(1:ndims(arr))) where {N, TA <:AbstractArray{<:Complex, N}}
93
+
functionfourier_filter_by_1D_FT!(arr::TA, wins::AbstractVector; transform_win=false, dims=(1:ndims(arr))) where {N, TA <:AbstractArray{<:Complex, N}}
94
+
ifisempty(dims)
95
+
return arr
96
+
end
29
97
# iterates of the dimension d using the corresponding shift
30
-
sz =size(arr)
31
98
for d in dims #(d, limit) in pairs(limits)
32
-
w =TA(ifftshift(fct(real(eltype(arr)), select_sizes(arr,d), border_in=border_in, border_out=border_out)))
# go back to real space now and return because shift_by_1D_FT processed
60
-
# the other dimensions already
61
-
mul!(arr, inv(p), arr_ft)
62
-
return arr # this breaks the for loop and finishes the algorithm
113
+
functionfourier_filter_by_1D_FT!(arr::TA, fct=window_gaussian; dims=(1:ndims(arr)), transform_win=false, kwargs...) where {N, TA <:AbstractArray{<:Complex, N}}
114
+
ifisempty(dims)
115
+
return arr
116
+
end
117
+
# iterates of the dimension d using the corresponding shift
functionfourier_filter_by_1D_RFT!(arr::TA, wins::AbstractVector; dims=(1:ndims(arr)), transform_win=false, kwargs...) where {T<:Real, N, TA<:AbstractArray{T, N}}
129
+
ifisempty(dims)
130
+
return arr
63
131
end
132
+
d = dims[1]
133
+
p =plan_rfft(arr, d)
134
+
135
+
arr_ft = p * arr
136
+
arr_ft .*=let
137
+
if transform_win
138
+
pw =plan_rfft(wins[d], d)
139
+
pw * wins[d]
140
+
else
141
+
wins[d]
142
+
end
143
+
end
144
+
# since we now did a single rfft dim, we can switch to the complex routine
145
+
# new_limits = ntuple(i -> i ≤ d ? 0 : limits[i], N)
# transforms the first dim as rft and then hands over to the fft-based routines.
155
+
functionfourier_filter_by_1D_RFT!(arr::TA, fct=window_gaussian; dims=(1:ndims(arr)), transform_win=false, kwargs...) where {T<:Real, N, TA<:AbstractArray{T, N}}
performs Gaussian filtering by multiplying a Gaussian function in Fourier space.
180
+
Note that this is not identical to the Fourier-transform of a real-space Gaussian, especially for small kernel sizes and small arrays.
181
+
See also `filter_gaussian!()` and `fourier_filter()`.
182
+
183
+
#Arguments
184
+
+`arr`: the array to filter
185
+
+`sigma`: the real-space standard deviation to filter with. From this the Fourier-space standard deviation will be calculated.
186
+
+`kwargs...`: additional arguments to be passed to `window_gaussian`, which is the underlying function from `IndexFunArray.jl`. This can be useful to create Fourier-shifted (Gabor-) filtering.
performs in-place Gaussian filtering by multiplying a Gaussian function in Fourier space.
196
+
Note that this is not identical to the Fourier-transform of a real-space Gaussian, especially for small kernel sizes and small arrays.
197
+
See also `filter_gaussian()` adn `fourier_filter!()`.
198
+
199
+
#Arguments
200
+
+`arr`: the array to filter
201
+
+`sigma`: the real-space standard deviation to filter with. From this the Fourier-space standard deviation will be calculated.
202
+
+`kwargs...`: additional arguments to be passed to `window_gaussian`, which is the underlying function from `IndexFunArray.jl`. This can be useful to create Fourier-shifted (Gabor-) filtering.
0 commit comments