Isosurface Generation Using VTK |
||||
VTK Basics |
||||
|
||||
3.5.3. Trying Different Colors and OpacitiesThe code from section 3.5.2 has been modified to provide two isosurfaces so it is possible to experiment with opacity and color of isosurfaces. Modifying actorBone.GetProperty().SetColor( 1, 1, 1 ) will change the color. Additionally, modifying actorBone.GetProperty().SetOpacity( 1 ) affects the transparency of the isosurface. To help you find the code to modify, it is highlighted. Farther below are three examples of different combinations. |
||||
import Tkinter import vtk from
vtk.tk.vtkTkRenderWindowInteractor import vtkTkRenderWindowInteractor # Prepare to read the file readerVolume =
vtk.vtkImageReader() readerVolume.SetDataScalarType(
vtk.VTK_UNSIGNED_SHORT ) readerVolume.SetFileDimensionality(
3 ) readerVolume.SetDataExtent (
0,255, 0,255, 0,576) readerVolume.SetDataSpacing(
1,1,1 ) readerVolume.SetNumberOfScalarComponents(
1 ) readerVolume.SetDataByteOrderToBigEndian() readerVolume.SetFileName(
"./Female.raw" ) # Extract the region of
interest voiHead = vtk.vtkExtractVOI() voiHead.SetInput(
readerVolume.GetOutput() ) voiHead.SetVOI( 0,255, 60,255,
0,100 ) voiHead.SetSampleRate( 1,1,1 ) #### BONE #contourBone =
vtk.vtkContourFilter() contourBone =
vtk.vtkMarchingCubes() contourBone.SetInput(
voiVolumeSection.GetOutput() ) contourBone.ComputeNormalsOn() contourBone.SetValue( 0, 1250 ) geoVolumeBone =
vtk.vtkPVGeometryFilter() geoVolumeBone.SetInput(
contourBone.GetOutput() ) geoBoneMapper =
vtk.vtkPolyDataMapper() geoBoneMapper.SetInput(
geoVolumeBone.GetOutput() ) geoBoneMapper.ScalarVisibilityOff() actorBone = vtk.vtkLODActor() actorBone.SetNumberOfCloudPoints(
1000000 ) actorBone.SetMapper(
geoBoneMapper ) actorBone.GetProperty().SetColor( 1, 1, 1 ) actorBone.GetProperty().SetOpacity( 1.0 ) ### SKIN #contourSkin =
vtk.vtkContourFilter() contourSkin =
vtk.vtkMarchingCubes() contourSkin.SetInput(
voiVolumeSection.GetOutput() ) contourSkin.SetValue( 0, 760 ) contourSkin.ComputeNormalsOn() geoVolumeSkin=
vtk.vtkPVGeometryFilter() geoVolumeSkin.SetInput( contourSkin.GetOutput()
) geoSkinMapper =
vtk.vtkPolyDataMapper() geoSkinMapper.SetInput(
geoVolumeSkin.GetOutput() ) geoSkinMapper.ScalarVisibilityOff() actorSkin = vtk.vtkLODActor() actorSkin.SetNumberOfCloudPoints(
1000000 ) actorSkin.SetMapper( geoSkinMapper
) actorSkin.GetProperty().SetColor( 1, 0.547237, 0.319073 ) actorSkin.GetProperty().SetOpacity( 0.3 ) # Create renderer ren = vtk.vtkRenderer() ren.SetBackground( 0.329412,
0.34902, 0.427451 ) #Paraview blue ren.AddActor(actorBone) ren.AddActor(actorSkin) # Create a window for the
renderer of size 250x250 renWin = vtk.vtkRenderWindow() renWin.AddRenderer(ren) renWin.SetSize(250, 250) # Set an user interface
interactor for the render window iren =
vtk.vtkRenderWindowInteractor() iren.SetRenderWindow(renWin) # Start the initialization and
rendering iren.Initialize() renWin.Render() iren.Start() Example 3.3:
Code for experimenting with isosurface color and opacity using two
isosurfaces |
||||
|
||||
|
|
|
||
SKIN Color: (1,
0.547237, 0.319073 ), Opacity: (0.3) BONE Color: ( 1,1,1
), Opacity: (1.0) |
SKIN Color: (0,
0.547237, 0.319073), Opacity: (0.5) BONE Color:
(1,1,1), Opacity: (0.3) |
SKIN Color: (0,0,1
), Opacity: (1.0) BONE Color:
(1,1,1), Opacity: (0.3) |
||
Figure 3.3:
Renderings of the head section of the Visible Woman dataset using a bone
isosurface value. |
||||
|
||||
vtkContourFilter
vs. vtkMarchingCubes |
|
Trying Different Volumes of Interest
and Sampling Rates |
||