33 |
33 |
34 ############################# |
34 ############################# |
35 # Base interpolation routine |
35 # Base interpolation routine |
36 ############################# |
36 ############################# |
37 |
37 |
38 @inline function interpolate2d_quadrants(v, (x, y)) |
38 @inline function interpolate2d_quadrants(v, x, y) |
39 (m, n) = size(v) |
39 (m, n) = size(v) |
40 clipx = xʹ -> max(1, min(xʹ, m)) |
40 clipx = xʹ -> max(1, min(xʹ, m)) |
41 clipy = yʹ -> max(1, min(yʹ, n)) |
41 clipy = yʹ -> max(1, min(yʹ, n)) |
42 |
42 |
43 xfℤ = clipx(floor(Int, x)) |
43 xfℤ = clipx(floor(Int, x)) |
99 function translate_image!(x, z, u::DisplacementFull) |
99 function translate_image!(x, z, u::DisplacementFull) |
100 @assert(size(u, 1)==2 && size(x)==size(u)[2:end] && size(x)==size(z)) |
100 @assert(size(u, 1)==2 && size(x)==size(u)[2:end] && size(x)==size(z)) |
101 |
101 |
102 Threads.@threads for i=1:size(x, 1) |
102 Threads.@threads for i=1:size(x, 1) |
103 @inbounds for j=1:size(x, 2) |
103 @inbounds for j=1:size(x, 2) |
104 pt = (i - u[1, i, j], j - u[2, i, j]) |
104 x[i, j] = interpolate2d_quadrants(z, i - u[1, i, j], j - u[2, i, j]) |
105 x[i, j] = interpolate2d_quadrants(z, pt) |
|
106 end |
105 end |
107 end |
106 end |
108 end |
107 end |
109 |
108 |
110 function translate_image!(x, z, u::DisplacementConstant) |
109 function translate_image!(x, z, u::DisplacementConstant) |
112 |
111 |
113 @inbounds a, b = u[1], u[2] |
112 @inbounds a, b = u[1], u[2] |
114 |
113 |
115 Threads.@threads for i=1:size(x, 1) |
114 Threads.@threads for i=1:size(x, 1) |
116 @inbounds for j=1:size(x, 2) |
115 @inbounds for j=1:size(x, 2) |
117 x[i, j] = interpolate2d_quadrants(z, (i - a, j - b)) |
116 x[i, j] = interpolate2d_quadrants(z, i - a, j - b) |
118 end |
117 end |
119 end |
118 end |
120 end |
119 end |
121 |
120 |
122 ###################### |
121 ###################### |