Commit 107e6ffc0c008f62c6efd6af97b6e65333f7b660

Authored by tfmoraes
1 parent a21f0c37

Forcing the mask buffer to be same dtype from mask

Showing 1 changed file with 9 additions and 5 deletions   Show diff stats
invesalius/data/slice_.py
@@ -441,7 +441,8 @@ class Slice(object): @@ -441,7 +441,8 @@ class Slice(object):
441 slice_number), 441 slice_number),
442 mask) 442 mask)
443 self.current_mask.matrix[n, 0, 0] = 1 443 self.current_mask.matrix[n, 0, 0] = 1
444 - n_mask = numpy.array(self.current_mask.matrix[n, 1:, 1:]) 444 + n_mask = numpy.array(self.current_mask.matrix[n, 1:, 1:],
  445 + dtype=self.current_mask.matrix.dtype)
445 446
446 elif orientation == 'CORONAL': 447 elif orientation == 'CORONAL':
447 if self.current_mask.matrix[0, n, 0] == 0: 448 if self.current_mask.matrix[0, n, 0] == 0:
@@ -450,7 +451,8 @@ class Slice(object): @@ -450,7 +451,8 @@ class Slice(object):
450 slice_number), 451 slice_number),
451 mask) 452 mask)
452 self.current_mask.matrix[0, n, 0] = 1 453 self.current_mask.matrix[0, n, 0] = 1
453 - n_mask = numpy.array(self.current_mask.matrix[1:, n, 1:]) 454 + n_mask = numpy.array(self.current_mask.matrix[1:, n, 1:],
  455 + dtype=self.current_mask.matrix.dtype)
454 456
455 elif orientation == 'SAGITAL': 457 elif orientation == 'SAGITAL':
456 if self.current_mask.matrix[0, 0, n] == 0: 458 if self.current_mask.matrix[0, 0, n] == 0:
@@ -459,7 +461,9 @@ class Slice(object): @@ -459,7 +461,9 @@ class Slice(object):
459 slice_number), 461 slice_number),
460 mask) 462 mask)
461 self.current_mask.matrix[0, 0, n] = 1 463 self.current_mask.matrix[0, 0, n] = 1
462 - n_mask = numpy.array(self.current_mask.matrix[1:, 1:, n]) 464 + n_mask = numpy.array(self.current_mask.matrix[1:, 1:, n],
  465 + dtype=self.current_mask.matrix.dtype)
  466 +
463 return n_mask 467 return n_mask
464 468
465 def GetNumberOfSlices(self, orientation): 469 def GetNumberOfSlices(self, orientation):
@@ -525,7 +529,7 @@ class Slice(object): @@ -525,7 +529,7 @@ class Slice(object):
525 else: 529 else:
526 print "Only one slice" 530 print "Only one slice"
527 slice_ = self.buffer_slices[orientation].image 531 slice_ = self.buffer_slices[orientation].image
528 - self.buffer_slices[orientation].mask = 255 * ((slice_ >= thresh_min) & (slice_ <= thresh_max)) 532 + self.buffer_slices[orientation].mask = (255 * ((slice_ >= thresh_min) & (slice_ <= thresh_max))).astype('uint8')
529 533
530 # Update viewer 534 # Update viewer
531 #ps.Publisher().sendMessage('Update slice viewer') 535 #ps.Publisher().sendMessage('Update slice viewer')
@@ -800,7 +804,7 @@ class Slice(object): @@ -800,7 +804,7 @@ class Slice(object):
800 m = (((slice_matrix >= thresh_min) & (slice_matrix <= thresh_max)) * 255) 804 m = (((slice_matrix >= thresh_min) & (slice_matrix <= thresh_max)) * 255)
801 m[mask == 1] = 1 805 m[mask == 1] = 1
802 m[mask == 254] = 254 806 m[mask == 254] = 254
803 - return m 807 + return m.astype('uint8')
804 808
805 def do_colour_image(self, imagedata): 809 def do_colour_image(self, imagedata):
806 # map scalar values into colors 810 # map scalar values into colors