Closed sebaseb98 closed 1 month ago
Thanks a lot for picking this up. The error actually goes a bit deeper. Using the sum of the data is just not the right way to normalize it. E.g. an array can be zero integral also by containing positive and negative values. I thus shifted the (optional) normalization to the kernel and introduced an optional argument, which seems more sensible. Such a normalization is advantageous for real-space Gaussians which are first transformed and then used for filtering. This is the preferred mode for small kernel sizes. Here is the pull request.
I tagged 0.4.6 So please update your package after it got merged https://github.com/bionanoimaging/FourierTools.jl/commit/3697e743847d7806ae8fff3f2d62b6adcf2ec9d5
the code
filter_gaussian(zeros(5))
returns [NaN, NaN, NaN, NaN, NaN].Not that it is too important to be able to filter zero arrays, but in my case I want to filter images column-wise and it could happen to have columns of zeros. For such cases I would prefer the package to return the correct result rather than work around this bug. When I looked into the code, I found that the division by the sum might cause the error (its line 315 in src/fourier_filtering.jl) or line 5 in the following snippet.
For this particular case a short check that
sum(arr) != 0
should do the job, but I am not sure how this fits in the philosophy of the whole package and if there are functions having the same problems