JuliaImages / ImageFiltering.jl

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

Possible bug with Inner() option #116

Closed juliohm closed 4 years ago

juliohm commented 4 years ago

Consider the following example:

using GeoStatsImages
using ImageFiltering
using Plots

# load an example 100x100 image
img = training_image("Strebelle")[1:100,1:100,1]

# trivial smoothing kernel
kern = ones(30,30)

# works as expected
res = imfilter(img, centered(kern), Algorithm.FFT())
heatmap(res)

Screenshot from 2019-11-07 21-24-22

# now with the Inner() option
res = imfilter(img, centered(kern), Inner(), Algorithm.FFT())
heatmap(res)

Screenshot from 2019-11-07 21-26-04

There is some strange offset. Could you please confirm the bug?

johnnychen94 commented 4 years ago

For FFT algorithm, kern will be shifted and padded to of the same size of img. Looks like the shifting and padding part doesn't work properly.

juliohm commented 4 years ago

It may also be a simpler bug like indexing the final result incorrectly to produce the inner part of the full image. If the result without inner is a OffsetArray for example doing res[30:100-30,30:100-30] may be innapropriate.

On Fri, Nov 8, 2019, 00:31 Johnny Chen notifications@github.com wrote:

For FFT algorithm, kern will be shifted and padded to of the same size of img. Looks like the shifting and padding part doesn't work properly.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/JuliaImages/ImageFiltering.jl/issues/116?email_source=notifications&email_token=AAZQW3KSTIMYE473LCDZXX3QSTMQZA5CNFSM4JKQOPA2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEDOTXSI#issuecomment-551369673, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZQW3O3UTH5HMIRHDHFPS3QSTMQZANCNFSM4JKQOPAQ .

juliohm commented 4 years ago

Appreciate if someone familiar with the code can take a look at this. ImageFiltering.jl is one of the few packages that I can't contribute straightforwardly, the code is advanced and full of indirect dispatch calls. Tried falling the calls with the debugger, but it still very challenging to find the point where the indexing is going wrong.

timholy commented 4 years ago

Test master. No release yet because we need to figure out the upper bounding of all of JuliaImages, and I haven't had time to do that yet.

juliohm commented 4 years ago

Tests fail for me on master:

Screenshot from 2019-11-09 15-12-11

However, the issue reported above does not happen.

timholy commented 4 years ago

Weird, it's passing on Travis: https://travis-ci.org/JuliaImages/ImageFiltering.jl?utm_medium=notification&utm_source=github_status

and AppVeyor: https://ci.appveyor.com/project/timholy/imagefiltering-jl/builds/28672293