# HG changeset patch # User Tuomo Valkonen # Date 1577473184 -7200 # Node ID 05b11c96ef4587c62b4528dbcd9bde6653c0fca6 # Parent d1f40f6654cbc8dd67fff173aca85be5d06f1c8c safeguards diff -r d1f40f6654cb -r 05b11c96ef45 src/ImFilter.jl --- a/src/ImFilter.jl Wed Dec 25 17:42:32 2019 +0200 +++ b/src/ImFilter.jl Fri Dec 27 20:59:44 2019 +0200 @@ -43,12 +43,12 @@ tmp = 0.0 it₁ = inside(i, a₁, b₁, 1, n) it₂ = inside(j, a₂, b₂, 1, m) - for p=it₁ + @inbounds for p=it₁ @simd for q=it₂ - tmp += @inbounds(kp[p-o₁, q-o₂]*b[i+p,j+q]) + tmp += kp[p-o₁, q-o₂]*b[i+p,j+q] end end - res[i, j] = tmp + @inbounds res[i, j] = tmp end end diff -r d1f40f6654cb -r 05b11c96ef45 src/Translate.jl --- a/src/Translate.jl Wed Dec 25 17:42:32 2019 +0200 +++ b/src/Translate.jl Fri Dec 27 20:59:44 2019 +0200 @@ -132,18 +132,18 @@ vyʹ = (imy-by)/2 - v[2] # Target image indices within source image - px = max(ceil(Int, max(1, vxʹ + 1) - vxʹ), 1) - py = max(ceil(Int, max(1, vyʹ + 1) - vyʹ), 1) - qx = min(floor(Int, min(imx, vxʹ + bx) - vxʹ), bx) - qy = min(floor(Int, min(imy, vyʹ + by) - vyʹ), by) + px = min(max(ceil(Int, max(1, vxʹ + 1) - vxʹ), 1), bx) + py = min(max(ceil(Int, max(1, vyʹ + 1) - vyʹ), 1), by) + qx = max(min(floor(Int, min(imx, vxʹ + bx) - vxʹ), bx), 1) + qy = max(min(floor(Int, min(imy, vyʹ + by) - vyʹ), by), 1) @inbounds begin b[1:px-1, :] .= 0 - b[qx+1:end, :] .= 0 + b[qx+1:bx, :] .= 0 Threads.@threads for i=px:qx b[i, 1:py-1] .= 0 - b[i, qy+1:end] .= 0 + b[i, qy+1:by] .= 0 @simd for j=py:qy b[i, j] = interpolate2d_quadrants(im, (i+vxʹ, j+vyʹ)) end