Commit e586881b3df2933bdaedb0173f57ccc1db70332c

Authored by Thiago Franco de Moraes
1 parent f2fa09e6

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 339 g = p['Green']
340 340 b = p['Blue']
341 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 353 self.color_transfer = color_transfer
349 354  
350 355 def CreateOpacityTable(self, scale):
... ... @@ -486,7 +491,7 @@ class Volume():
486 491 convolve = vtk.vtkImageConvolve()
487 492 convolve.SetInputData(imagedata)
488 493 convolve.SetKernel5x5([i/60.0 for i in Kernels[filter]])
489   - convolve.ReleaseDataFlagOn()
  494 + # convolve.ReleaseDataFlagOn()
490 495  
491 496 convolve_ref = weakref.ref(convolve)
492 497  
... ... @@ -533,7 +538,7 @@ class Volume():
533 538 flip.SetInputData(image)
534 539 flip.SetFilteredAxis(1)
535 540 flip.FlipAboutOriginOn()
536   - flip.ReleaseDataFlagOn()
  541 + # flip.ReleaseDataFlagOn()
537 542  
538 543 flip_ref = weakref.ref(flip)
539 544 flip_ref().AddObserver("ProgressEvent", lambda obj,evt:
... ... @@ -548,7 +553,7 @@ class Volume():
548 553 cast.SetInputData(image)
549 554 cast.SetShift(abs(scale[0]))
550 555 cast.SetOutputScalarTypeToUnsignedShort()
551   - cast.ReleaseDataFlagOn()
  556 + # cast.ReleaseDataFlagOn()
552 557 cast_ref = weakref.ref(cast)
553 558 cast_ref().AddObserver("ProgressEvent", lambda obj,evt:
554 559 update_progress(cast_ref(), "Rendering..."))
... ... @@ -660,7 +665,7 @@ class Volume():
660 665 accumulate.SetInputData(image)
661 666 accumulate.SetComponentExtent(0, r -1, 0, 0, 0, 0)
662 667 accumulate.SetComponentOrigin(image.GetScalarRange()[0], 0, 0)
663   - accumulate.ReleaseDataFlagOn()
  668 + # accumulate.ReleaseDataFlagOn()
664 669 accumulate.Update()
665 670 n_image = numpy_support.vtk_to_numpy(accumulate.GetOutput().GetPointData().GetScalars())
666 671 del accumulate
... ...