Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
RainerHeintzmann committed Sep 16, 2024
1 parent 9e9f30d commit ec61ecb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/fourier_filtering.jl
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,9 @@ function fourier_filter_by_1D_RFT!(arr::TA, fct=window_gaussian; dims=(1:ndims(a
end
end
arr_ft .*= win
fourier_filter_by_1D_FT!(arr_ft, fct; dims=dims[2:end], transform_win=transform_win, kwargs...)

# hand over to the fft-based routines for all other dimensions
fourier_filter_by_1D_FT!(arr_ft, fct; dims=dims[2:end], transform_win=transform_win, keep_integral=keep_integral, kwargs...)
# go back to real space now and return because shift_by_1D_FT processed
# the other dimensions already
mul!(arr, inv(p), arr_ft)
Expand Down
4 changes: 2 additions & 2 deletions test/fourier_filtering.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ Random.seed!(42)
@testset "Gaussian filter real" begin
sz = (21, 22)
x = randn(Float32, sz)
sigma = (1.1,2.2)
sigma = (1.1, 2.2)
gf = filter_gaussian(x, sigma, real_space_kernel=true)
# Note that this is not the same, since one kernel is generated in real space and one in Fourier space!
# with sizes around 10, the difference is huge!
k = gaussian(sz, sigma=sigma)
k = k./sum(k) # different than "normal".
gf2 = conv_psf(x, k)
@test (gf,gf2, rtol=1e-2) # it is realatively inaccurate due to the kernel being generated in different places
@test (gf, gf2, rtol=1e-2) # it is realatively inaccurate due to the kernel being generated in different places
gf2 = filter_gaussian(zeros(sz), sigma, real_space_kernel=true)
@test (gf2, zeros(sz)) # it can be debated how to best normalize a Gaussian filter
end
Expand Down

0 comments on commit ec61ecb

Please sign in to comment.