JuliaImages / ImageFiltering.jl

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

`imfilter` ignores `Fill` values when`Fill` bounds are explicitly specified or inferred from a kernel #85

Closed zygmuntszpak closed 5 years ago

zygmuntszpak commented 5 years ago
using ImageFiltering, , Test

A = rand(8,8)

# If you don't explicitly specify the amount of padding then the `Fill` value
# is taken into account and, as anticipated,  affects the outcome of the result. 
r1 = imfilter(A, Kernel.gaussian((1,1),(3,3)), Fill(0))
r2 = imfilter(A, Kernel.gaussian((1,1),(3,3)), Fill(10))
@test r1[4,4] == r2[4,4]
@test r1[1,1] != r2[1,1]

# If you specify the amount of padding as a tuple then the `Fill` value
# is not taken into account.
r1 = imfilter(A, Kernel.gaussian((1,1),(3,3)), Fill(0, (3,3)))
r2 = imfilter(A, Kernel.gaussian((1,1),(3,3)), Fill(10, (3,3)))
@test r1[4,4] == r2[4,4]
@test r1[1,1] != r2[1,1] # Test fails

r1 = imfilter(A, Kernel.gaussian((1,1),(3,3)), Fill(0, (3,3),(3,3)))
r2 = imfilter(A, Kernel.gaussian((1,1),(3,3)), Fill(10, (3,3), (3,3)))
@test r1[4,4] == r2[4,4]
@test r1[1,1] != r2[1,1] # Test fails

# If you specify the amount of padding as an array then the `Fill` value
# is not taken into account.
r1 = imfilter(A, Kernel.gaussian((1,1),(3,3)), Fill(0, [3,3],[3,3]))
r2 = imfilter(A, Kernel.gaussian((1,1),(3,3)), Fill(10, [3,3], [3,3]))
@test r1[4,4] == r2[4,4]
@test r1[1,1] != r2[1,1] # Test fails

# If you specify the kernel so that the minimum required padding is applied
# the `Fill` value is not taken into account.
r1 = imfilter(A, Kernel.gaussian((1,1),(3,3)), Fill(0, Kernel.gaussian((1,1),(3,3))))
r2 = imfilter(A, Kernel.gaussian((1,1),(3,3)), Fill(10, Kernel.gaussian((1,1),(3,3))))
@test r1[4,4] == r2[4,4]
@test r1[1,1] != r2[1,1] # Test fails