Commit b6b1506bed151f054fc20b54bb85121814549987
1 parent
9a6b5311
Exists in
master
and in
6 other branches
ENH: Progress values fixed in the raycast
Showing
1 changed file
with
20 additions
and
17 deletions
Show diff stats
invesalius/data/volume.py
... | ... | @@ -385,16 +385,17 @@ class Volume(): |
385 | 385 | self.volume_properties.SetSpecular(shading['specular']) |
386 | 386 | self.volume_properties.SetSpecularPower(shading['specularPower']) |
387 | 387 | |
388 | - def ApplyConvolution(self, imagedata): | |
388 | + def ApplyConvolution(self, imagedata, update_progress = None): | |
389 | 389 | number_filters = len(self.config['convolutionFilters']) |
390 | 390 | if number_filters: |
391 | - update_progress= vtk_utils.ShowProgress(number_filters) | |
391 | + if not(update_progress): | |
392 | + update_progress = vtk_utils.ShowProgress(number_filters) | |
392 | 393 | for filter in self.config['convolutionFilters']: |
393 | 394 | convolve = vtk.vtkImageConvolve() |
394 | 395 | convolve.SetInput(imagedata) |
395 | 396 | convolve.SetKernel5x5([i/60.0 for i in Kernels[filter]]) |
396 | 397 | convolve.AddObserver("ProgressEvent", lambda obj,evt: |
397 | - update_progress(convolve, "%s ..." % filter)) | |
398 | + update_progress(convolve, "Rendering...")) | |
398 | 399 | imagedata = convolve.GetOutput() |
399 | 400 | #convolve.GetOutput().ReleaseDataFlagOn() |
400 | 401 | return imagedata |
... | ... | @@ -402,8 +403,9 @@ class Volume(): |
402 | 403 | def LoadVolume(self): |
403 | 404 | proj = prj.Project() |
404 | 405 | image = proj.imagedata |
405 | - | |
406 | - update_progress= vtk_utils.ShowProgress(4) | |
406 | + | |
407 | + number_filters = len(self.config['convolutionFilters']) | |
408 | + update_progress= vtk_utils.ShowProgress(2 + number_filters) | |
407 | 409 | |
408 | 410 | # Flip original vtkImageData |
409 | 411 | flip = vtk.vtkImageFlip() |
... | ... | @@ -411,7 +413,7 @@ class Volume(): |
411 | 413 | flip.SetFilteredAxis(1) |
412 | 414 | flip.FlipAboutOriginOn() |
413 | 415 | flip.AddObserver("ProgressEvent", lambda obj,evt: |
414 | - update_progress(flip, "Fliping ...")) | |
416 | + update_progress(flip, "Rendering...")) | |
415 | 417 | flip.Update() |
416 | 418 | |
417 | 419 | image = flip.GetOutput() |
... | ... | @@ -424,7 +426,7 @@ class Volume(): |
424 | 426 | cast.SetShift(abs(scale[0])) |
425 | 427 | cast.SetOutputScalarTypeToUnsignedShort() |
426 | 428 | cast.AddObserver("ProgressEvent", lambda obj,evt: |
427 | - update_progress(cast, "Casting ...")) | |
429 | + update_progress(cast, "Rendering...")) | |
428 | 430 | cast.Update() |
429 | 431 | image2 = cast |
430 | 432 | self.imagedata = image2 |
... | ... | @@ -434,7 +436,9 @@ class Volume(): |
434 | 436 | else: |
435 | 437 | self.Create8bColorTable(scale) |
436 | 438 | self.Create8bOpacityTable(scale) |
437 | - image2 = self.ApplyConvolution(image2.GetOutput()) | |
439 | + | |
440 | + | |
441 | + image2 = self.ApplyConvolution(image2.GetOutput(), update_progress) | |
438 | 442 | self.final_imagedata = image2 |
439 | 443 | |
440 | 444 | composite_function = vtk.vtkVolumeRayCastCompositeFunction() |
... | ... | @@ -449,21 +453,21 @@ class Volume(): |
449 | 453 | if const.TYPE_RAYCASTING_MAPPER: |
450 | 454 | volume_mapper = vtk.vtkVolumeRayCastMapper() |
451 | 455 | #volume_mapper.AutoAdjustSampleDistancesOff() |
452 | - volume_mapper.SetInput(image2) | |
456 | + #volume_mapper.SetInput(image2) | |
453 | 457 | volume_mapper.SetVolumeRayCastFunction(composite_function) |
454 | 458 | #volume_mapper.SetGradientEstimator(gradientEstimator) |
455 | 459 | volume_mapper.IntermixIntersectingGeometryOn() |
456 | 460 | else: |
457 | 461 | volume_mapper = vtk.vtkFixedPointVolumeRayCastMapper() |
458 | 462 | #volume_mapper.AutoAdjustSampleDistancesOff() |
459 | - volume_mapper.SetInput(image2) | |
463 | + | |
460 | 464 | volume_mapper.IntermixIntersectingGeometryOn() |
461 | 465 | #volume_mapper.SetBlendModeToMaximumIntensity() |
462 | - | |
463 | - volume_mapper.AddObserver("ProgressEvent", lambda obj,evt: | |
464 | - update_progress(volume_mapper, "Mapper ...")) | |
466 | + volume_mapper.SetInput(image2) | |
465 | 467 | self.volume_mapper = volume_mapper |
466 | - | |
468 | + | |
469 | + | |
470 | + | |
467 | 471 | # TODO: Look to this |
468 | 472 | #volume_mapper_hw = vtk.vtkVolumeTextureMapper3D() |
469 | 473 | #volume_mapper_hw.SetInput(image2) |
... | ... | @@ -496,14 +500,12 @@ class Volume(): |
496 | 500 | volume_mapper.SetImageSampleDistance(0.25) |
497 | 501 | volume_mapper.SetSampleDistance(pix_diag / 5.0) |
498 | 502 | volume_properties.SetScalarOpacityUnitDistance(pix_diag) |
499 | - | |
503 | + | |
500 | 504 | self.volume_properties = volume_properties |
501 | 505 | |
502 | 506 | volume = vtk.vtkVolume() |
503 | 507 | volume.SetMapper(volume_mapper) |
504 | 508 | volume.SetProperty(volume_properties) |
505 | - volume.AddObserver("ProgressEvent", lambda obj,evt: | |
506 | - update_progress(volume, "Volume ...")) | |
507 | 509 | self.volume = volume |
508 | 510 | |
509 | 511 | colour = self.GetBackgroundColour() |
... | ... | @@ -511,6 +513,7 @@ class Volume(): |
511 | 513 | ps.Publisher().sendMessage('Load volume into viewer', |
512 | 514 | (volume, colour, (self.ww, self.wl))) |
513 | 515 | |
516 | + | |
514 | 517 | def OnEnableTool(self, pubsub_evt): |
515 | 518 | print "OnEnableTool" |
516 | 519 | tool_name, enable = pubsub_evt.data | ... | ... |