Commit f9191b324a5a2df396fdeb878932f1106ceb1d40
1 parent
99677689
Exists in
master
and in
68 other branches
ENH: Improved the raycasting quality
Showing
1 changed file
with
12 additions
and
4 deletions
Show diff stats
invesalius/data/volume.py
... | ... | @@ -343,7 +343,7 @@ class Volume(): |
343 | 343 | image2 = convolve |
344 | 344 | |
345 | 345 | composite_function = vtk.vtkVolumeRayCastCompositeFunction() |
346 | - composite_function.SetCompositeMethodToClassifyFirst() | |
346 | + composite_function.SetCompositeMethodToInterpolateFirst() | |
347 | 347 | |
348 | 348 | gradientEstimator = vtk.vtkFiniteDifferenceGradientEstimator() |
349 | 349 | gradientEstimator.SetGradientMagnitudeScale(1) |
... | ... | @@ -352,9 +352,9 @@ class Volume(): |
352 | 352 | #volume_mapper.AutoAdjustSampleDistancesOff() |
353 | 353 | volume_mapper.SetInput(image2.GetOutput()) |
354 | 354 | volume_mapper.SetVolumeRayCastFunction(composite_function) |
355 | - volume_mapper.SetGradientEstimator(gradientEstimator) | |
355 | + #volume_mapper.SetGradientEstimator(gradientEstimator) | |
356 | 356 | volume_mapper.IntermixIntersectingGeometryOn() |
357 | - | |
357 | + | |
358 | 358 | #Cut Plane |
359 | 359 | CutPlane(image2.GetOutput(), volume_mapper) |
360 | 360 | |
... | ... | @@ -369,13 +369,21 @@ class Volume(): |
369 | 369 | |
370 | 370 | volume_properties.SetInterpolationTypeToLinear() |
371 | 371 | volume_properties.SetColor(self.color_transfer) |
372 | - self.volume_properties = volume_properties | |
373 | 372 | |
374 | 373 | try: |
375 | 374 | volume_properties.SetScalarOpacity(self.opacity_transfer_func) |
376 | 375 | except NameError: |
377 | 376 | pass |
378 | 377 | |
378 | + # Using these lines to improve the raycasting quality. These values | |
379 | + # seems related to the distance from ray from raycasting. | |
380 | + # TODO: Need to see values that improve the quality and don't decrease | |
381 | + # the performance. 2.0 seems to be a good value to pix_diag | |
382 | + pix_diag = 2.0 | |
383 | + volume_mapper.SetImageSampleDistance(0.25) | |
384 | + volume_mapper.SetSampleDistance(pix_diag / 5.0) | |
385 | + volume_properties.SetScalarOpacityUnitDistance(pix_diag) | |
386 | + | |
379 | 387 | self.volume_properties = volume_properties |
380 | 388 | |
381 | 389 | volume = vtk.vtkVolume() | ... | ... |