Skip to content

Commit 5087d8f

Browse files
fixes
1 parent 2399ba4 commit 5087d8f

File tree

4 files changed

+17
-14
lines changed

4 files changed

+17
-14
lines changed

src/imfilter.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ function buffered_planned_irfft(a::AbstractArray{T}) where {T}
858858
end
859859

860860
function planned_fft(A::AbstractArray{T,N},
861-
kernel::Tuple{AbstractArray,Vararg{AbstractArray}},
861+
kernel::ProcessedKernel,
862862
border::BorderSpecAny=Pad(:replicate)
863863
) where {T,N}
864864
bord = border(kernel, A, Algorithm.FFT())
@@ -870,6 +870,8 @@ function planned_fft(A::AbstractArray{T,N},
870870
bfp3 = buffered_planned_irfft(_A)
871871
return Algorithm.FFT(bfp1, bfp2, bfp3)
872872
end
873+
planned_fft(A::AbstractArray, kernel, border::AbstractString) = planned_fft(A, kernel, borderinstance(border))
874+
planned_fft(A::AbstractArray, kernel::Union{ArrayLike,Laplacian}, border::BorderSpecAny) = planned_fft(A, factorkernel(kernel), border)
873875

874876
function filtfft(A, krn, planned_rfft1::Function, planned_rfft2::Function, planned_irfft::Function)
875877
B = complex(planned_rfft1(A))

test/2d.jl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ end
5050
# Dense inseparable kernel
5151
kern = [0.1 0.2; 0.4 0.5]
5252
kernel = OffsetArray(kern, -1:0, 1:2)
53+
border = Inner()
5354
for img in (imgf, imgi, imgg, imgc)
5455
targetimg = zeros(typeof(img[1]*kern[1]), size(img))
5556
targetimg[3:4,2:3] = rot180(kern) .* img[3,4]
@@ -76,12 +77,12 @@ end
7677
@test_throws MethodError imfilter!(CPU1(Algorithm.FIR()), ret, img, kernel, border, Algorithm.FFT())
7778
end
7879
targetimg_inner = OffsetArray(targetimg[2:end, 1:end-2], 2:5, 1:5)
79-
@test @inferred(imfilter(img, kernel, Inner())) targetimg_inner
80-
@test @inferred(imfilter(f32type(img), img, kernel, Inner())) float32.(targetimg_inner)
80+
@test @inferred(imfilter(img, kernel, border)) targetimg_inner
81+
@test @inferred(imfilter(f32type(img), img, kernel, border)) float32.(targetimg_inner)
8182
for alg in (Algorithm.FIR(), Algorithm.FIRTiled(), Algorithm.FFT(), planned_fft(img, kernel, border))
82-
@test @inferred(imfilter(img, kernel, Inner(), alg)) targetimg_inner
83-
@test @inferred(imfilter(f32type(img), img, kernel, Inner(), alg)) float32.(targetimg_inner)
84-
@test @inferred(imfilter(CPU1(alg), img, kernel, Inner())) targetimg_inner
83+
@test @inferred(imfilter(img, kernel, border, alg)) targetimg_inner
84+
@test @inferred(imfilter(f32type(img), img, kernel, border, alg)) float32.(targetimg_inner)
85+
@test @inferred(imfilter(CPU1(alg), img, kernel, border)) targetimg_inner
8586
end
8687
end
8788
# Factored kernel

test/nd.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ end
129129
img = trues(10,10,10)
130130
kernel = centered(trues(3,3,3)/27)
131131
for border in ("replicate", "circular", "symmetric", "reflect", Fill(true))
132-
for alg in (Algorithm.FIR(), Algorithm.FIRTiled(), Algorithm.FFT(), planned_fft(img, kernel, border))
132+
# TODO: add support for boolean images in planned_fft
133+
for alg in (Algorithm.FIR(), Algorithm.FIRTiled(), Algorithm.FFT())
133134
@test imfilter(img, kernel, border) img
134135
end
135136
end

test/runtests.jl

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ using ImageQualityIndexes
66
import StaticArrays
77
using Random
88

9+
function typestring(::Type{T}) where T # from https://github.com/JuliaImages/ImageCore.jl/pull/133
10+
buf = IOBuffer()
11+
show(buf, T)
12+
String(take!(buf))
13+
end
14+
915
@testset "ImageFiltering" verbose=true begin
1016
@testset "Project meta quality checks" begin
1117
# Ambiguity test
@@ -27,12 +33,6 @@ using Random
2733
end
2834
end
2935

30-
function typestring(::Type{T}) where T # from https://github.com/JuliaImages/ImageCore.jl/pull/133
31-
buf = IOBuffer()
32-
show(buf, T)
33-
String(take!(buf))
34-
end
35-
3636
include("compat.jl")
3737
include("border.jl")
3838
include("nd.jl")
@@ -50,7 +50,6 @@ include("models.jl")
5050

5151
CUDA_INSTALLED = false
5252
try
53-
global CUDA_INSTALLED
5453
# This errors with `IOError` when nvidia driver is not available,
5554
# in which case we don't even need to try `using CUDA`
5655
run(pipeline(`nvidia-smi`, stdout=devnull, stderr=devnull))

0 commit comments

Comments
 (0)