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 441 slice_number),
442 442 mask)
443 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 447 elif orientation == 'CORONAL':
447 448 if self.current_mask.matrix[0, n, 0] == 0:
... ... @@ -450,7 +451,8 @@ class Slice(object):
450 451 slice_number),
451 452 mask)
452 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 457 elif orientation == 'SAGITAL':
456 458 if self.current_mask.matrix[0, 0, n] == 0:
... ... @@ -459,7 +461,9 @@ class Slice(object):
459 461 slice_number),
460 462 mask)
461 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 467 return n_mask
464 468  
465 469 def GetNumberOfSlices(self, orientation):
... ... @@ -525,7 +529,7 @@ class Slice(object):
525 529 else:
526 530 print "Only one slice"
527 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 534 # Update viewer
531 535 #ps.Publisher().sendMessage('Update slice viewer')
... ... @@ -800,7 +804,7 @@ class Slice(object):
800 804 m = (((slice_matrix >= thresh_min) & (slice_matrix <= thresh_max)) * 255)
801 805 m[mask == 1] = 1
802 806 m[mask == 254] = 254
803   - return m
  807 + return m.astype('uint8')
804 808  
805 809 def do_colour_image(self, imagedata):
806 810 # map scalar values into colors
... ...