safety min-max

Thu, 19 Dec 2019 21:38:03 +0200

author
Tuomo Valkonen <tuomov@iki.fi>
date
Thu, 19 Dec 2019 21:38:03 +0200
changeset 23
64a3f09e5fa7
parent 22
4403f0445814
child 24
f6630036e588

safety min-max

src/Translate.jl file | annotate | diff | comparison | revisions
--- a/src/Translate.jl	Wed Dec 18 20:56:36 2019 +0200
+++ b/src/Translate.jl	Thu Dec 19 21:38:03 2019 +0200
@@ -132,10 +132,10 @@
     vyʹ = (imy-by)/2 - v[2]
 
     # Target image indices within source image
-    px = ceil(Int, max(1, vxʹ + 1) - vxʹ)
-    py = ceil(Int, max(1, vyʹ + 1) - vyʹ)
-    qx = floor(Int, min(imx, vxʹ + bx) - vxʹ)
-    qy = floor(Int, min(imy, vyʹ + by) - vyʹ)
+    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)
     
     @inbounds begin
         b[1:px-1, :] .= 0

mercurial