Commit 3368fa085e246376303ec5dab0dc013fc6330e47
1 parent
914780e9
Exists in
master
and in
3 other branches
Border size independent in each orientation
Showing
2 changed files
with
18 additions
and
14 deletions
Show diff stats
invesalius/data/slice_.py
@@ -438,14 +438,16 @@ class Slice(object): | @@ -438,14 +438,16 @@ class Slice(object): | ||
438 | self.buffer_slices[orientation].discard_vtk_mask() | 438 | self.buffer_slices[orientation].discard_vtk_mask() |
439 | 439 | ||
440 | 440 | ||
441 | - def GetSlices(self, orientation, slice_number, number_slices, inverted=False): | 441 | + def GetSlices(self, orientation, slice_number, number_slices, |
442 | + inverted=False, border_size=1.0): | ||
442 | if self.buffer_slices[orientation].index == slice_number and \ | 443 | if self.buffer_slices[orientation].index == slice_number and \ |
443 | self._type_projection == const.PROJECTION_NORMAL: | 444 | self._type_projection == const.PROJECTION_NORMAL: |
444 | if self.buffer_slices[orientation].vtk_image: | 445 | if self.buffer_slices[orientation].vtk_image: |
445 | image = self.buffer_slices[orientation].vtk_image | 446 | image = self.buffer_slices[orientation].vtk_image |
446 | else: | 447 | else: |
447 | n_image = self.get_image_slice(orientation, slice_number, | 448 | n_image = self.get_image_slice(orientation, slice_number, |
448 | - number_slices, inverted) | 449 | + number_slices, inverted, |
450 | + border_size) | ||
449 | image = converters.to_vtk(n_image, self.spacing, slice_number, orientation) | 451 | image = converters.to_vtk(n_image, self.spacing, slice_number, orientation) |
450 | ww_wl_image = self.do_ww_wl(image) | 452 | ww_wl_image = self.do_ww_wl(image) |
451 | image = self.do_colour_image(ww_wl_image) | 453 | image = self.do_colour_image(ww_wl_image) |
@@ -466,7 +468,7 @@ class Slice(object): | @@ -466,7 +468,7 @@ class Slice(object): | ||
466 | self.buffer_slices[orientation].vtk_image = image | 468 | self.buffer_slices[orientation].vtk_image = image |
467 | else: | 469 | else: |
468 | n_image = self.get_image_slice(orientation, slice_number, | 470 | n_image = self.get_image_slice(orientation, slice_number, |
469 | - number_slices, inverted) | 471 | + number_slices, inverted, border_size) |
470 | image = converters.to_vtk(n_image, self.spacing, slice_number, orientation) | 472 | image = converters.to_vtk(n_image, self.spacing, slice_number, orientation) |
471 | ww_wl_image = self.do_ww_wl(image) | 473 | ww_wl_image = self.do_ww_wl(image) |
472 | image = self.do_colour_image(ww_wl_image) | 474 | image = self.do_colour_image(ww_wl_image) |
@@ -489,7 +491,8 @@ class Slice(object): | @@ -489,7 +491,8 @@ class Slice(object): | ||
489 | 491 | ||
490 | return final_image | 492 | return final_image |
491 | 493 | ||
492 | - def get_image_slice(self, orientation, slice_number, number_slices=1, inverted=False): | 494 | + def get_image_slice(self, orientation, slice_number, number_slices=1, |
495 | + inverted=False, border_size=1.0): | ||
493 | if self.buffer_slices[orientation].index == slice_number \ | 496 | if self.buffer_slices[orientation].index == slice_number \ |
494 | and self.buffer_slices[orientation].image is not None: | 497 | and self.buffer_slices[orientation].image is not None: |
495 | n_image = self.buffer_slices[orientation].image | 498 | n_image = self.buffer_slices[orientation].image |
@@ -524,19 +527,19 @@ class Slice(object): | @@ -524,19 +527,19 @@ class Slice(object): | ||
524 | n_image = numpy.empty(shape=(tmp_array.shape[1], | 527 | n_image = numpy.empty(shape=(tmp_array.shape[1], |
525 | tmp_array.shape[2]), | 528 | tmp_array.shape[2]), |
526 | dtype=tmp_array.dtype) | 529 | dtype=tmp_array.dtype) |
527 | - mips.fast_countour_mip(tmp_array, self.n_border, 0, self.window_level, | 530 | + mips.fast_countour_mip(tmp_array, border_size, 0, self.window_level, |
528 | self.window_level, 0, n_image) | 531 | self.window_level, 0, n_image) |
529 | elif self._type_projection == const.PROJECTION_CONTOUR_LMIP: | 532 | elif self._type_projection == const.PROJECTION_CONTOUR_LMIP: |
530 | n_image = numpy.empty(shape=(tmp_array.shape[1], | 533 | n_image = numpy.empty(shape=(tmp_array.shape[1], |
531 | tmp_array.shape[2]), | 534 | tmp_array.shape[2]), |
532 | dtype=tmp_array.dtype) | 535 | dtype=tmp_array.dtype) |
533 | - mips.fast_countour_mip(tmp_array, self.n_border, 0, self.window_level, | 536 | + mips.fast_countour_mip(tmp_array, border_size, 0, self.window_level, |
534 | self.window_level, 1, n_image) | 537 | self.window_level, 1, n_image) |
535 | elif self._type_projection == const.PROJECTION_CONTOUR_MIDA: | 538 | elif self._type_projection == const.PROJECTION_CONTOUR_MIDA: |
536 | n_image = numpy.empty(shape=(tmp_array.shape[1], | 539 | n_image = numpy.empty(shape=(tmp_array.shape[1], |
537 | tmp_array.shape[2]), | 540 | tmp_array.shape[2]), |
538 | dtype=tmp_array.dtype) | 541 | dtype=tmp_array.dtype) |
539 | - mips.fast_countour_mip(tmp_array, self.n_border, 0, self.window_level, | 542 | + mips.fast_countour_mip(tmp_array, border_size, 0, self.window_level, |
540 | self.window_level, 2, n_image) | 543 | self.window_level, 2, n_image) |
541 | else: | 544 | else: |
542 | n_image = numpy.array(self.matrix[slice_number]) | 545 | n_image = numpy.array(self.matrix[slice_number]) |
@@ -572,19 +575,19 @@ class Slice(object): | @@ -572,19 +575,19 @@ class Slice(object): | ||
572 | n_image = numpy.empty(shape=(tmp_array.shape[0], | 575 | n_image = numpy.empty(shape=(tmp_array.shape[0], |
573 | tmp_array.shape[2]), | 576 | tmp_array.shape[2]), |
574 | dtype=tmp_array.dtype) | 577 | dtype=tmp_array.dtype) |
575 | - mips.fast_countour_mip(tmp_array, self.n_border, 1, self.window_level, | 578 | + mips.fast_countour_mip(tmp_array, border_size, 1, self.window_level, |
576 | self.window_level, 0, n_image) | 579 | self.window_level, 0, n_image) |
577 | elif self._type_projection == const.PROJECTION_CONTOUR_LMIP: | 580 | elif self._type_projection == const.PROJECTION_CONTOUR_LMIP: |
578 | n_image = numpy.empty(shape=(tmp_array.shape[0], | 581 | n_image = numpy.empty(shape=(tmp_array.shape[0], |
579 | tmp_array.shape[2]), | 582 | tmp_array.shape[2]), |
580 | dtype=tmp_array.dtype) | 583 | dtype=tmp_array.dtype) |
581 | - mips.fast_countour_mip(tmp_array, self.n_border, 1, self.window_level, | 584 | + mips.fast_countour_mip(tmp_array, border_size, 1, self.window_level, |
582 | self.window_level, 1, n_image) | 585 | self.window_level, 1, n_image) |
583 | elif self._type_projection == const.PROJECTION_CONTOUR_MIDA: | 586 | elif self._type_projection == const.PROJECTION_CONTOUR_MIDA: |
584 | n_image = numpy.empty(shape=(tmp_array.shape[0], | 587 | n_image = numpy.empty(shape=(tmp_array.shape[0], |
585 | tmp_array.shape[2]), | 588 | tmp_array.shape[2]), |
586 | dtype=tmp_array.dtype) | 589 | dtype=tmp_array.dtype) |
587 | - mips.fast_countour_mip(tmp_array, self.n_border, 1, self.window_level, | 590 | + mips.fast_countour_mip(tmp_array, border_size, 1, self.window_level, |
588 | self.window_level, 2, n_image) | 591 | self.window_level, 2, n_image) |
589 | else: | 592 | else: |
590 | n_image = numpy.array(self.matrix[..., slice_number, ...]) | 593 | n_image = numpy.array(self.matrix[..., slice_number, ...]) |
@@ -617,19 +620,19 @@ class Slice(object): | @@ -617,19 +620,19 @@ class Slice(object): | ||
617 | n_image = numpy.empty(shape=(tmp_array.shape[0], | 620 | n_image = numpy.empty(shape=(tmp_array.shape[0], |
618 | tmp_array.shape[1]), | 621 | tmp_array.shape[1]), |
619 | dtype=tmp_array.dtype) | 622 | dtype=tmp_array.dtype) |
620 | - mips.fast_countour_mip(tmp_array, self.n_border, 2, self.window_level, | 623 | + mips.fast_countour_mip(tmp_array, border_size, 2, self.window_level, |
621 | self.window_level, 0, n_image) | 624 | self.window_level, 0, n_image) |
622 | elif self._type_projection == const.PROJECTION_CONTOUR_LMIP: | 625 | elif self._type_projection == const.PROJECTION_CONTOUR_LMIP: |
623 | n_image = numpy.empty(shape=(tmp_array.shape[0], | 626 | n_image = numpy.empty(shape=(tmp_array.shape[0], |
624 | tmp_array.shape[1]), | 627 | tmp_array.shape[1]), |
625 | dtype=tmp_array.dtype) | 628 | dtype=tmp_array.dtype) |
626 | - mips.fast_countour_mip(tmp_array, self.n_border, 2, self.window_level, | 629 | + mips.fast_countour_mip(tmp_array, border_size, 2, self.window_level, |
627 | self.window_level, 1, n_image) | 630 | self.window_level, 1, n_image) |
628 | elif self._type_projection == const.PROJECTION_CONTOUR_MIDA: | 631 | elif self._type_projection == const.PROJECTION_CONTOUR_MIDA: |
629 | n_image = numpy.empty(shape=(tmp_array.shape[0], | 632 | n_image = numpy.empty(shape=(tmp_array.shape[0], |
630 | tmp_array.shape[1]), | 633 | tmp_array.shape[1]), |
631 | dtype=tmp_array.dtype) | 634 | dtype=tmp_array.dtype) |
632 | - mips.fast_countour_mip(tmp_array, self.n_border, 2, self.window_level, | 635 | + mips.fast_countour_mip(tmp_array, border_size, 2, self.window_level, |
633 | self.window_level, 2, n_image) | 636 | self.window_level, 2, n_image) |
634 | else: | 637 | else: |
635 | n_image = numpy.array(self.matrix[..., ..., slice_number]) | 638 | n_image = numpy.array(self.matrix[..., ..., slice_number]) |
invesalius/data/viewer_slice.py
@@ -1233,8 +1233,9 @@ class Viewer(wx.Panel): | @@ -1233,8 +1233,9 @@ class Viewer(wx.Panel): | ||
1233 | 1233 | ||
1234 | def set_slice_number(self, index): | 1234 | def set_slice_number(self, index): |
1235 | inverted = self.mip_ctrls.inverted.GetValue() | 1235 | inverted = self.mip_ctrls.inverted.GetValue() |
1236 | + border_size = self.mip_ctrls.border_spin.GetValue() | ||
1236 | image = self.slice_.GetSlices(self.orientation, index, | 1237 | image = self.slice_.GetSlices(self.orientation, index, |
1237 | - self.number_slices, inverted) | 1238 | + self.number_slices, inverted, border_size) |
1238 | self.slice_data.actor.SetInput(image) | 1239 | self.slice_data.actor.SetInput(image) |
1239 | for actor in self.actors_by_slice_number.get(self.slice_data.number, []): | 1240 | for actor in self.actors_by_slice_number.get(self.slice_data.number, []): |
1240 | self.slice_data.renderer.RemoveActor(actor) | 1241 | self.slice_data.renderer.RemoveActor(actor) |