Commit 161ef11e92feda6f8f7fcd9b5bf2156f10572767

Authored by Thiago Franco de Moraes
1 parent 39bc71f4

FIX: edition when the brush is bigger than the slice

Showing 1 changed file with 10 additions and 12 deletions   Show diff stats
invesalius/data/slice_.py
@@ -427,20 +427,18 @@ class Slice(object): @@ -427,20 +427,18 @@ class Slice(object):
427 roi_m = mask[yi:yf,xi:xf] 427 roi_m = mask[yi:yf,xi:xf]
428 roi_i = image[yi:yf, xi:xf] 428 roi_i = image[yi:yf, xi:xf]
429 429
430 - if operation == const.BRUSH_THRESH:  
431 - # It's a trick to make points between threshold gets value 254  
432 - # (1 * 253 + 1) and out ones gets value 1 (0 * 253 + 1).  
433 - try: 430 + # Checking if roi_i has at least one element.
  431 + if numpy.product(roi_i.shape):
  432 + if operation == const.BRUSH_THRESH:
  433 + # It's a trick to make points between threshold gets value 254
  434 + # (1 * 253 + 1) and out ones gets value 1 (0 * 253 + 1).
434 roi_m[index] = (((roi_i[index] >= thresh_min) 435 roi_m[index] = (((roi_i[index] >= thresh_min)
435 & (roi_i[index] <= thresh_max)) * 253) + 1 436 & (roi_i[index] <= thresh_max)) * 253) + 1
436 - except IndexError:  
437 - # Resolving the problem when roi_i has 0 elements.  
438 - pass  
439 - elif operation == const.BRUSH_DRAW:  
440 - roi_m[index] = 254  
441 - elif operation == const.BRUSH_ERASE:  
442 - roi_m[index] = 1  
443 - self.buffer_slices[orientation].discard_vtk_mask() 437 + elif operation == const.BRUSH_DRAW:
  438 + roi_m[index] = 254
  439 + elif operation == const.BRUSH_ERASE:
  440 + roi_m[index] = 1
  441 + self.buffer_slices[orientation].discard_vtk_mask()
444 442
445 443
446 def GetSlices(self, orientation, slice_number, number_slices, 444 def GetSlices(self, orientation, slice_number, number_slices,