94 |
96 |
95 ############## |
97 ############## |
96 # Translation |
98 # Translation |
97 ############## |
99 ############## |
98 |
100 |
99 function translate_image!(x, z, u::DisplacementFull) |
101 function translate_image!(x, z, u::DisplacementFull; |
|
102 threads::Bool=false) |
100 @assert(size(u, 1)==2 && size(x)==size(u)[2:end] && size(x)==size(z)) |
103 @assert(size(u, 1)==2 && size(x)==size(u)[2:end] && size(x)==size(z)) |
101 |
104 |
102 Threads.@threads for i=1:size(x, 1) |
105 @threadsif threads for i=1:size(x, 1) |
103 @inbounds for j=1:size(x, 2) |
106 for j=1:size(x, 2) |
104 x[i, j] = interpolate2d_quadrants(z, i - u[1, i, j], j - u[2, i, j]) |
107 x[i, j] = interpolate2d_quadrants(z, i - u[1, i, j], j - u[2, i, j]) |
105 end |
108 end |
106 end |
109 end |
107 end |
110 end |
108 |
111 |
109 function translate_image!(x, z, u::DisplacementConstant) |
112 function translate_image!(x, z, u::DisplacementConstant; |
|
113 threads::Bool=false) |
110 @assert(size(u)==(2,) && size(x)==size(z)) |
114 @assert(size(u)==(2,) && size(x)==size(z)) |
111 |
115 |
112 @inbounds a, b = u[1], u[2] |
116 @inbounds a, b = u[1], u[2] |
113 |
117 |
114 Threads.@threads for i=1:size(x, 1) |
118 @threadsif threads for i=1:size(x, 1) |
115 @inbounds for j=1:size(x, 2) |
119 for j=1:size(x, 2) |
116 x[i, j] = interpolate2d_quadrants(z, i - a, j - b) |
120 x[i, j] = interpolate2d_quadrants(z, i - a, j - b) |
117 end |
121 end |
118 end |
122 end |
119 end |
123 end |
120 |
124 |
121 ###################### |
125 ###################### |
122 # Subimage extraction |
126 # Subimage extraction |
123 ###################### |
127 ###################### |
124 |
128 |
125 function extract_subimage!(b, im, v::DisplacementConstant) |
129 function extract_subimage!(b, im, v::DisplacementConstant; |
|
130 threads::Bool=false) |
126 (imx, imy) = size(im) |
131 (imx, imy) = size(im) |
127 (bx, by) = size(b) |
132 (bx, by) = size(b) |
128 |
133 |
129 # Translation from target to source coordinates |
134 # Translation from target to source coordinates |
130 vxʹ = (imx-bx)/2 - v[1] |
135 vxʹ = (imx-bx)/2 - v[1] |