125 @polly function extract_subimage!(b, im, v::DisplacementConstant) |
125 @polly function extract_subimage!(b, im, v::DisplacementConstant) |
126 (imx, imy) = size(im) |
126 (imx, imy) = size(im) |
127 (bx, by) = size(b) |
127 (bx, by) = size(b) |
128 |
128 |
129 # Translation from target to source coordinates |
129 # Translation from target to source coordinates |
130 vxʹ = v[1] + (imx-bx)/2 |
130 vxʹ = (imx-bx)/2 - v[1] |
131 vyʹ = v[2] + (imy-by)/2 |
131 vyʹ = (imy-by)/2 - v[2] |
132 |
132 |
133 # Target image indices within source image |
133 # Target image indices within source image |
134 px = ceil(Int, max(1, vxʹ + 1) - vxʹ) |
134 px = ceil(Int, max(1, vxʹ + 1) - vxʹ) |
135 py = ceil(Int, max(1, vyʹ + 1) - vyʹ) |
135 py = ceil(Int, max(1, vyʹ + 1) - vyʹ) |
136 qx = floor(Int, min(imx, vxʹ + bx) - vxʹ) |
136 qx = floor(Int, min(imx, vxʹ + bx) - vxʹ) |