ImageFiltering.jl icon indicating copy to clipboard operation
ImageFiltering.jl copied to clipboard

Strange automagic kernel centering depending on eltype

Open jw3126 opened this issue 3 years ago • 2 comments

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 avatar Feb 24 '22 09:02 jw3126

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 avatar Feb 24 '22 10:02 jw3126

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

jw3126 avatar Feb 24 '22 10:02 jw3126