Skip to content

Commit 2cb3c2d

Browse files
committed
fix x2 >= image_width and y2 >= image_height
1 parent 11971e8 commit 2cb3c2d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

modules/masking.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ def expand_too_small_crop_region(crop_region, processing_width, processing_heigh
8989
diff_w_r = diff_w - diff_w_l
9090
x1 -= diff_w_l
9191
x2 += diff_w_r
92+
if x2 >= image_width:
93+
diff = x2 - image_width
94+
x2 -= diff
95+
x1 -= diff
9296
if x1 < 0:
9397
x2 -= x1
9498
x1 -= x1
@@ -102,6 +106,10 @@ def expand_too_small_crop_region(crop_region, processing_width, processing_heigh
102106
diff_h_d = diff_h - diff_h_u
103107
y1 -= diff_h_u
104108
y2 += diff_h_d
109+
if y2 >= image_height:
110+
diff = y2 - image_height
111+
y2 -= diff
112+
y1 -= diff
105113
if y1 < 0:
106114
y2 -= y1
107115
y1 -= y1

0 commit comments

Comments
 (0)