Skip to content

Commit 75f89d0

Browse files
authored
Don't use FFT when input has NaNs (#157)
1 parent c3f2a6c commit 75f89d0

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/imfilter.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1532,7 +1532,7 @@ end
15321532
# allocated by the time this gets called.
15331533
function filter_algorithm(out, img, kernel::Union{ArrayType,Tuple{Vararg{ArrayType}}})
15341534
L = maxlen(kernel)
1535-
if L > 30 && eltype(img) <: Union{Number,Colorant}
1535+
if L > 30 && eltype(img) <: Union{Number,Colorant} && !any(isnan,img)
15361536
return FFT()
15371537
end
15381538
sz = map(length, calculate_padding(kernel))

test/nd.jl

+3
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ Base.zero(::Type{WrappedFloat}) = WrappedFloat(0.0)
9292
@test all(x->x==0, imgf[first(inds):-2]) && all(x->x==0, imgf[2:last(inds)])
9393
end
9494

95+
# Input with NaN
96+
@test isnan.(imfilter([NaN;1:100],centered(ones(31)))) == ((0:100) .<= 15)
97+
9598
# Issue #110
9699
img = reinterpret(WrappedFloat, rand(128))
97100
kern = centered(rand(31))

0 commit comments

Comments
 (0)