Previous

Section

<<<

Isosurface Generation Using VTK

Next

Section

>>>

VTK Basics

 

 

3.5.4. Trying Different Volumes of Interest and Sampling Rates

 

This is the same code from section 3.5.3.  Try some different sampling rates and volumes of interest.  Remember, it is only possible to use integers, so there will be some factor of difference from one sampling rate to another.  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 )

 

### 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.4: Code for experimenting with volume of interest and sampling rates

 

Sampling Rate: (1,1,1)

Volume of Interest:

 (0,255, 60,255, 0,100)

Sampling Rate: (1,1,1)

Volume of Interest:

 (0,255, 60,255, 476,576)

Sampling Rate: (1,1,1)

Volume of Interest:

 (0,255, 60,255, 0,100)

 

 

 

Sampling Rate: (2,2,1)

Volume of Interest:

 (0,255, 60,255, 0,100)

Sampling Rate: (3,3,1)

Volume of Interest:

 (0,255, 60,255, 476,576)

Sampling Rate: (4,4,1)

Volume of Interest:

 (0,255, 60,255, 0,100)

Figure 3.4: Renderings of various volumes of interest using different sampling rates. 

 

 

<<< Previous

Trying Different Colors and Opacities

 

Table of Contents

 

Next >>>

Creating the Application