Commit e23f8647c719f144393dbe2ab752893cc64145e3
1 parent
ec966667
Exists in
master
and in
3 other branches
Defined border in a object's variable
Showing
1 changed file
with
24 additions
and
10 deletions
Show diff stats
invesalius/data/slice_.py
@@ -86,6 +86,7 @@ class Slice(object): | @@ -86,6 +86,7 @@ class Slice(object): | ||
86 | self._matrix = None | 86 | self._matrix = None |
87 | 87 | ||
88 | self._type_projection = const.PROJECTION_MIDA | 88 | self._type_projection = const.PROJECTION_MIDA |
89 | + self.n_border = 3.0 | ||
89 | 90 | ||
90 | self.spacing = (1.0, 1.0, 1.0) | 91 | self.spacing = (1.0, 1.0, 1.0) |
91 | 92 | ||
@@ -514,7 +515,7 @@ class Slice(object): | @@ -514,7 +515,7 @@ class Slice(object): | ||
514 | n_image = numpy.empty(shape=(tmp_array.shape[1], | 515 | n_image = numpy.empty(shape=(tmp_array.shape[1], |
515 | tmp_array.shape[2]), | 516 | tmp_array.shape[2]), |
516 | dtype=tmp_array.dtype) | 517 | dtype=tmp_array.dtype) |
517 | - mips.fast_countour_mip(tmp_array, 0.2, 0, self.window_level, | 518 | + mips.fast_countour_mip(tmp_array, self.n_border, 0, self.window_level, |
518 | self.window_level, 0, n_image) | 519 | self.window_level, 0, n_image) |
519 | elif self._type_projection == const.PROJECTION_CONTOUR_LMIP: | 520 | elif self._type_projection == const.PROJECTION_CONTOUR_LMIP: |
520 | tmp_array = numpy.array(self.matrix[slice_number: | 521 | tmp_array = numpy.array(self.matrix[slice_number: |
@@ -522,7 +523,7 @@ class Slice(object): | @@ -522,7 +523,7 @@ class Slice(object): | ||
522 | n_image = numpy.empty(shape=(tmp_array.shape[1], | 523 | n_image = numpy.empty(shape=(tmp_array.shape[1], |
523 | tmp_array.shape[2]), | 524 | tmp_array.shape[2]), |
524 | dtype=tmp_array.dtype) | 525 | dtype=tmp_array.dtype) |
525 | - mips.fast_countour_mip(tmp_array, 0.2, 0, self.window_level, | 526 | + mips.fast_countour_mip(tmp_array, self.n_border, 0, self.window_level, |
526 | self.window_level, 1, n_image) | 527 | self.window_level, 1, n_image) |
527 | elif self._type_projection == const.PROJECTION_CONTOUR_MIDA: | 528 | elif self._type_projection == const.PROJECTION_CONTOUR_MIDA: |
528 | tmp_array = numpy.array(self.matrix[slice_number: | 529 | tmp_array = numpy.array(self.matrix[slice_number: |
@@ -530,7 +531,7 @@ class Slice(object): | @@ -530,7 +531,7 @@ class Slice(object): | ||
530 | n_image = numpy.empty(shape=(tmp_array.shape[1], | 531 | n_image = numpy.empty(shape=(tmp_array.shape[1], |
531 | tmp_array.shape[2]), | 532 | tmp_array.shape[2]), |
532 | dtype=tmp_array.dtype) | 533 | dtype=tmp_array.dtype) |
533 | - mips.fast_countour_mip(tmp_array, 0.2, 0, self.window_level, | 534 | + mips.fast_countour_mip(tmp_array, self.n_border, 0, self.window_level, |
534 | self.window_level, 2, n_image) | 535 | self.window_level, 2, n_image) |
535 | else: | 536 | else: |
536 | n_image = numpy.array(self.matrix[slice_number]) | 537 | n_image = numpy.array(self.matrix[slice_number]) |
@@ -567,7 +568,7 @@ class Slice(object): | @@ -567,7 +568,7 @@ class Slice(object): | ||
567 | n_image = numpy.empty(shape=(tmp_array.shape[0], | 568 | n_image = numpy.empty(shape=(tmp_array.shape[0], |
568 | tmp_array.shape[2]), | 569 | tmp_array.shape[2]), |
569 | dtype=tmp_array.dtype) | 570 | dtype=tmp_array.dtype) |
570 | - mips.fast_countour_mip(tmp_array, 0.2, 1, self.window_level, | 571 | + mips.fast_countour_mip(tmp_array, self.n_border, 1, self.window_level, |
571 | self.window_level, 0, n_image) | 572 | self.window_level, 0, n_image) |
572 | elif self._type_projection == const.PROJECTION_CONTOUR_LMIP: | 573 | elif self._type_projection == const.PROJECTION_CONTOUR_LMIP: |
573 | tmp_array = numpy.array(self.matrix[..., slice_number: | 574 | tmp_array = numpy.array(self.matrix[..., slice_number: |
@@ -575,7 +576,7 @@ class Slice(object): | @@ -575,7 +576,7 @@ class Slice(object): | ||
575 | n_image = numpy.empty(shape=(tmp_array.shape[0], | 576 | n_image = numpy.empty(shape=(tmp_array.shape[0], |
576 | tmp_array.shape[2]), | 577 | tmp_array.shape[2]), |
577 | dtype=tmp_array.dtype) | 578 | dtype=tmp_array.dtype) |
578 | - mips.fast_countour_mip(tmp_array, 0.2, 1, self.window_level, | 579 | + mips.fast_countour_mip(tmp_array, self.n_border, 1, self.window_level, |
579 | self.window_level, 1, n_image) | 580 | self.window_level, 1, n_image) |
580 | elif self._type_projection == const.PROJECTION_CONTOUR_MIDA: | 581 | elif self._type_projection == const.PROJECTION_CONTOUR_MIDA: |
581 | tmp_array = numpy.array(self.matrix[..., slice_number: | 582 | tmp_array = numpy.array(self.matrix[..., slice_number: |
@@ -583,7 +584,7 @@ class Slice(object): | @@ -583,7 +584,7 @@ class Slice(object): | ||
583 | n_image = numpy.empty(shape=(tmp_array.shape[0], | 584 | n_image = numpy.empty(shape=(tmp_array.shape[0], |
584 | tmp_array.shape[2]), | 585 | tmp_array.shape[2]), |
585 | dtype=tmp_array.dtype) | 586 | dtype=tmp_array.dtype) |
586 | - mips.fast_countour_mip(tmp_array, 0.2, 1, self.window_level, | 587 | + mips.fast_countour_mip(tmp_array, self.n_border, 1, self.window_level, |
587 | self.window_level, 2, n_image) | 588 | self.window_level, 2, n_image) |
588 | else: | 589 | else: |
589 | n_image = numpy.array(self.matrix[..., slice_number, ...]) | 590 | n_image = numpy.array(self.matrix[..., slice_number, ...]) |
@@ -620,7 +621,7 @@ class Slice(object): | @@ -620,7 +621,7 @@ class Slice(object): | ||
620 | n_image = numpy.empty(shape=(tmp_array.shape[0], | 621 | n_image = numpy.empty(shape=(tmp_array.shape[0], |
621 | tmp_array.shape[1]), | 622 | tmp_array.shape[1]), |
622 | dtype=tmp_array.dtype) | 623 | dtype=tmp_array.dtype) |
623 | - mips.fast_countour_mip(tmp_array, 0.2, 2, self.window_level, | 624 | + mips.fast_countour_mip(tmp_array, self.n_border, 2, self.window_level, |
624 | self.window_level, 0, n_image) | 625 | self.window_level, 0, n_image) |
625 | elif self._type_projection == const.PROJECTION_CONTOUR_LMIP: | 626 | elif self._type_projection == const.PROJECTION_CONTOUR_LMIP: |
626 | tmp_array = numpy.array(self.matrix[..., ..., | 627 | tmp_array = numpy.array(self.matrix[..., ..., |
@@ -628,7 +629,7 @@ class Slice(object): | @@ -628,7 +629,7 @@ class Slice(object): | ||
628 | n_image = numpy.empty(shape=(tmp_array.shape[0], | 629 | n_image = numpy.empty(shape=(tmp_array.shape[0], |
629 | tmp_array.shape[1]), | 630 | tmp_array.shape[1]), |
630 | dtype=tmp_array.dtype) | 631 | dtype=tmp_array.dtype) |
631 | - mips.fast_countour_mip(tmp_array, 0.2, 2, self.window_level, | 632 | + mips.fast_countour_mip(tmp_array, self.n_border, 2, self.window_level, |
632 | self.window_level, 1, n_image) | 633 | self.window_level, 1, n_image) |
633 | elif self._type_projection == const.PROJECTION_CONTOUR_MIDA: | 634 | elif self._type_projection == const.PROJECTION_CONTOUR_MIDA: |
634 | tmp_array = numpy.array(self.matrix[..., ..., | 635 | tmp_array = numpy.array(self.matrix[..., ..., |
@@ -636,7 +637,7 @@ class Slice(object): | @@ -636,7 +637,7 @@ class Slice(object): | ||
636 | n_image = numpy.empty(shape=(tmp_array.shape[0], | 637 | n_image = numpy.empty(shape=(tmp_array.shape[0], |
637 | tmp_array.shape[1]), | 638 | tmp_array.shape[1]), |
638 | dtype=tmp_array.dtype) | 639 | dtype=tmp_array.dtype) |
639 | - mips.fast_countour_mip(tmp_array, 0.2, 2, self.window_level, | 640 | + mips.fast_countour_mip(tmp_array, self.n_border, 2, self.window_level, |
640 | self.window_level, 2, n_image) | 641 | self.window_level, 2, n_image) |
641 | else: | 642 | else: |
642 | n_image = numpy.array(self.matrix[..., ..., slice_number]) | 643 | n_image = numpy.array(self.matrix[..., ..., slice_number]) |
@@ -832,6 +833,12 @@ class Slice(object): | @@ -832,6 +833,12 @@ class Slice(object): | ||
832 | def GetOutput(self): | 833 | def GetOutput(self): |
833 | return self.blend_filter.GetOutput() | 834 | return self.blend_filter.GetOutput() |
834 | 835 | ||
836 | + def SetTypeProjection(self, tprojection): | ||
837 | + if self._type_projection != tprojection: | ||
838 | + self._type_projection = tprojection | ||
839 | + for buffer_ in self.buffer_slices.values(): | ||
840 | + buffer_.discard_buffer() | ||
841 | + | ||
835 | def SetInput(self, imagedata, mask_dict): | 842 | def SetInput(self, imagedata, mask_dict): |
836 | print "SETINPUT!" | 843 | print "SETINPUT!" |
837 | self.imagedata = imagedata | 844 | self.imagedata = imagedata |
@@ -891,7 +898,14 @@ class Slice(object): | @@ -891,7 +898,14 @@ class Slice(object): | ||
891 | self.window_level = level | 898 | self.window_level = level |
892 | 899 | ||
893 | for buffer_ in self.buffer_slices.values(): | 900 | for buffer_ in self.buffer_slices.values(): |
894 | - buffer_.discard_vtk_image() | 901 | + if self._type_projection in (const.PROJECTION_NORMAL, |
902 | + const.PROJECTION_MaxIP, | ||
903 | + const.PROJECTION_MinIP, | ||
904 | + const.PROJECTION_MeanIP, | ||
905 | + const.PROJECTION_LMIP): | ||
906 | + buffer_.discard_vtk_image() | ||
907 | + else: | ||
908 | + buffer_.discard_buffer() | ||
895 | 909 | ||
896 | Publisher.sendMessage('Reload actual slice') | 910 | Publisher.sendMessage('Reload actual slice') |
897 | 911 |