Commit e586881b3df2933bdaedb0173f57ccc1db70332c
1 parent
f2fa09e6
Exists in
master
and in
23 other branches
Black & White raycasting was not working because of lack of colortable
Showing
1 changed file
with
15 additions
and
10 deletions
Show diff stats
invesalius/data/volume.py
@@ -339,12 +339,17 @@ class Volume(): | @@ -339,12 +339,17 @@ class Volume(): | ||
339 | g = p['Green'] | 339 | g = p['Green'] |
340 | b = p['Blue'] | 340 | b = p['Blue'] |
341 | colors = zip(r,g,b) | 341 | colors = zip(r,g,b) |
342 | - ww = self.config['ww'] | ||
343 | - wl = self.TranslateScale(scale, self.config['wl']) | ||
344 | - init = wl - ww/2.0 | ||
345 | - inc = ww / (len(colors) - 1.0) | ||
346 | - for n,rgb in enumerate(colors): | ||
347 | - color_transfer.AddRGBPoint(init + n * inc, *[i/255.0 for i in rgb]) | 342 | + else: |
343 | + # Grayscale from black to white | ||
344 | + colors = [(i, i, i) for i in xrange(256)] | ||
345 | + | ||
346 | + ww = self.config['ww'] | ||
347 | + wl = self.TranslateScale(scale, self.config['wl']) | ||
348 | + init = wl - ww/2.0 | ||
349 | + inc = ww / (len(colors) - 1.0) | ||
350 | + for n,rgb in enumerate(colors): | ||
351 | + color_transfer.AddRGBPoint(init + n * inc, *[i/255.0 for i in rgb]) | ||
352 | + | ||
348 | self.color_transfer = color_transfer | 353 | self.color_transfer = color_transfer |
349 | 354 | ||
350 | def CreateOpacityTable(self, scale): | 355 | def CreateOpacityTable(self, scale): |
@@ -486,7 +491,7 @@ class Volume(): | @@ -486,7 +491,7 @@ class Volume(): | ||
486 | convolve = vtk.vtkImageConvolve() | 491 | convolve = vtk.vtkImageConvolve() |
487 | convolve.SetInputData(imagedata) | 492 | convolve.SetInputData(imagedata) |
488 | convolve.SetKernel5x5([i/60.0 for i in Kernels[filter]]) | 493 | convolve.SetKernel5x5([i/60.0 for i in Kernels[filter]]) |
489 | - convolve.ReleaseDataFlagOn() | 494 | + # convolve.ReleaseDataFlagOn() |
490 | 495 | ||
491 | convolve_ref = weakref.ref(convolve) | 496 | convolve_ref = weakref.ref(convolve) |
492 | 497 | ||
@@ -533,7 +538,7 @@ class Volume(): | @@ -533,7 +538,7 @@ class Volume(): | ||
533 | flip.SetInputData(image) | 538 | flip.SetInputData(image) |
534 | flip.SetFilteredAxis(1) | 539 | flip.SetFilteredAxis(1) |
535 | flip.FlipAboutOriginOn() | 540 | flip.FlipAboutOriginOn() |
536 | - flip.ReleaseDataFlagOn() | 541 | + # flip.ReleaseDataFlagOn() |
537 | 542 | ||
538 | flip_ref = weakref.ref(flip) | 543 | flip_ref = weakref.ref(flip) |
539 | flip_ref().AddObserver("ProgressEvent", lambda obj,evt: | 544 | flip_ref().AddObserver("ProgressEvent", lambda obj,evt: |
@@ -548,7 +553,7 @@ class Volume(): | @@ -548,7 +553,7 @@ class Volume(): | ||
548 | cast.SetInputData(image) | 553 | cast.SetInputData(image) |
549 | cast.SetShift(abs(scale[0])) | 554 | cast.SetShift(abs(scale[0])) |
550 | cast.SetOutputScalarTypeToUnsignedShort() | 555 | cast.SetOutputScalarTypeToUnsignedShort() |
551 | - cast.ReleaseDataFlagOn() | 556 | + # cast.ReleaseDataFlagOn() |
552 | cast_ref = weakref.ref(cast) | 557 | cast_ref = weakref.ref(cast) |
553 | cast_ref().AddObserver("ProgressEvent", lambda obj,evt: | 558 | cast_ref().AddObserver("ProgressEvent", lambda obj,evt: |
554 | update_progress(cast_ref(), "Rendering...")) | 559 | update_progress(cast_ref(), "Rendering...")) |
@@ -660,7 +665,7 @@ class Volume(): | @@ -660,7 +665,7 @@ class Volume(): | ||
660 | accumulate.SetInputData(image) | 665 | accumulate.SetInputData(image) |
661 | accumulate.SetComponentExtent(0, r -1, 0, 0, 0, 0) | 666 | accumulate.SetComponentExtent(0, r -1, 0, 0, 0, 0) |
662 | accumulate.SetComponentOrigin(image.GetScalarRange()[0], 0, 0) | 667 | accumulate.SetComponentOrigin(image.GetScalarRange()[0], 0, 0) |
663 | - accumulate.ReleaseDataFlagOn() | 668 | + # accumulate.ReleaseDataFlagOn() |
664 | accumulate.Update() | 669 | accumulate.Update() |
665 | n_image = numpy_support.vtk_to_numpy(accumulate.GetOutput().GetPointData().GetScalars()) | 670 | n_image = numpy_support.vtk_to_numpy(accumulate.GetOutput().GetPointData().GetScalars()) |
666 | del accumulate | 671 | del accumulate |