我有一堆图像(3D 阵列),我想提高它们的分辨率(上采样)。我运行以下代码片段,我发现它有点慢......
有什么办法可以提高这段代码的速度吗?(不使用多处理)
using BenchmarkTools
using Interpolations
function doInterpol(arr::Array{Int, 2}, h, w)
A = interpolate(arr, BSpline(Linear()))
return A[1:2/(h-1)/2:2, 1:2/(w-1)/2:2]
end
function applyResize!(arr3D_hd::Array, arr3D_ld::Array, t::Int, h::Int, w::Int)
for i = 1:1:t
@inbounds arr3D_hd[i, :, :] = doInterpol(arr3D_ld[i, :, :], h, w)
end
end
t, h, w = 502, 65, 47
h_target, w_target = 518, 412
arr3D_ld = reshape(collect(1:t*h*w), (t, h, w))
arr3D_hd = Array{Float32}(undef, t, h_target, w_target)
applyResize!(arr3D_hd, arr3D_ld, t, h_target, w_target)
Run Code Online (Sandbox Code Playgroud)
当我对以下内容进行基准测试时:
@btime applyResize!(arr3D_hd, arr3D_ld, t, h_target, w_target)
Run Code Online (Sandbox Code Playgroud)
我有 : …
interpolation image image-processing multidimensional-array julia