From 39bc71f427194047a71e30c0f59a149b43e1b742 Mon Sep 17 00:00:00 2001 From: Thiago Franco de Moraes Date: Fri, 25 Oct 2013 14:40:20 -0200 Subject: [PATCH] FIX: edition when the brush is bigger than the slice --- invesalius/data/slice_.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/invesalius/data/slice_.py b/invesalius/data/slice_.py index 125cb79..8e7eb6e 100644 --- a/invesalius/data/slice_.py +++ b/invesalius/data/slice_.py @@ -419,18 +419,23 @@ class Slice(object): xf = image.shape[1] # Verifying if the points is over the image array. - if (not 0 < xi < image.shape[1] and not 0 < xf < image.shape[1]) or \ - (not 0 < yi < image.shape[0] and not 0 < yf < image.shape[0]): + if (not 0 <= xi <= image.shape[1] and not 0 <= xf <= image.shape[1]) or \ + (not 0 <= yi <= image.shape[0] and not 0 <= yf <= image.shape[0]): return + roi_m = mask[yi:yf,xi:xf] roi_i = image[yi:yf, xi:xf] if operation == const.BRUSH_THRESH: # It's a trick to make points between threshold gets value 254 # (1 * 253 + 1) and out ones gets value 1 (0 * 253 + 1). - roi_m[index] = (((roi_i[index] >= thresh_min) - & (roi_i[index] <= thresh_max)) * 253) + 1 + try: + roi_m[index] = (((roi_i[index] >= thresh_min) + & (roi_i[index] <= thresh_max)) * 253) + 1 + except IndexError: + # Resolving the problem when roi_i has 0 elements. + pass elif operation == const.BRUSH_DRAW: roi_m[index] = 254 elif operation == const.BRUSH_ERASE: -- libgit2 0.21.2