JuliaImages / ImageFiltering.jl

Julia implementations of multidimensional array convolution and nonlinear stencil operations
Other
99 stars 51 forks source link

Strange automagic kernel centering depending on eltype #245

Open jw3126 opened 2 years ago

jw3126 commented 2 years ago
using ImageFiltering

@assert imfilter(       [0, 0, 1, 0, 0], [1, 1]) == [  1, 1  ,   0, 0  , 0]
@assert imfilter(Float64[0, 0, 1, 0, 0], [1, 1])  ≈ [0.0, 1.0, 1.0, 0.0, 0.0]
jw3126 commented 2 years ago

Digging a bit into the implementation, it almost looks like the magic kernel centering is intended and the bug is that in the Int case there is no such centering?

https://github.com/JuliaImages/ImageFiltering.jl/blob/47fae0a0f5f23a44f6ecd895bc3576c0ae7ab337/src/imfilter.jl#L10 https://github.com/JuliaImages/ImageFiltering.jl/blob/47fae0a0f5f23a44f6ecd895bc3576c0ae7ab337/src/imfilter.jl#L1503

OTOH my impression was, that a design principle of this package is to avoid magic like implicit kernel centering?

jw3126 commented 2 years ago

If somebody can clarify I can make a PR to document the intended behavior and fix the unintended behavior.