Hi everyone, this is my first post here. I used vtkplotter to show a 3d model starting from dicom scans with the following code:
import vtk
from vtkplotter import *
import numpy as np
from vtkmodules.vtkCommonDataModel import vtkPiecewiseFunction
from vtkmodules.vtkRenderingCore import vtkRenderer, vtkVolume, vtkVolumeProperty, vtkColorTransferFunction
volume = load('Letter:/path')
volumeColor = vtkColorTransferFunction()
r, g, b = getColor('white')
volumeColor.AddRGBPoint(-1024, r, g, b)
r, g, b = getColor('yellow')
volumeColor.AddRGBPoint(-1023, r, g, b)
r, g, b = getColor('blue')
volumeColor.AddRGBPoint(-1022, r, g, b)
volumeScalarOpacity = vtkPiecewiseFunction()
volumeScalarOpacity.AddPoint(-1024, 0.00)
volumeScalarOpacity.AddPoint(-1023, 0.5)
volumeScalarOpacity.AddPoint(-1022, 0.5)
volumeProperty = vtkVolumeProperty()
volumeProperty.SetColor(volumeColor)
volumeProperty.SetScalarOpacity(volumeScalarOpacity)
volumeProperty.SetInterpolationTypeToLinear()
volumeProperty.ShadeOn()
volumeProperty.SetAmbient(0.4)
volumeProperty.SetDiffuse(0.6)
volumeProperty.SetSpecular(0.2)
volume.SetProperty(volumeProperty)
show(volume)
How can I change the opacity values dynamically with a slider?
Thanks in advance for your answers