diff --git a/impy/viewer/keybinds.py b/impy/viewer/keybinds.py index b4cd8b77..b094fa9c 100644 --- a/impy/viewer/keybinds.py +++ b/impy/viewer/keybinds.py @@ -361,8 +361,8 @@ def _crop_rectangle(img, crds, dims): translate = np.empty(2) for i in [0, 1]: sl0 = sorted([start[i], end[i]]) - x0 = int(sl0[0])+1 - x1 = int(sl0[1])+1 + x0 = max(int(sl0[0]), 0) + x1 = min(int(sl0[1]), img.sizeof(dims[i])) sl.append(f"{dims[i]}={x0}:{x1}") translate[i] = x0