[vtkusers] Voulme Rendering

suhai suh at rpi.edu
Wed Apr 24 01:39:06 EDT 2002


Dear All
I am fresher in VTK. Now I try to reconstruct a series of 2D ultrasound image to 3D using VoulmeRendering. My dataset is BMP grey image(0-255, one byte per pixel). I use threshold to get rid of some noise and use gaussian smooth to smooth the original image and then to render it. But I can not get the right result. I used another comerical software can succeed in voulmerendering those dataset. I do not know why? Could anybody help me to figure it out?

The following is the source code I used.



package require vtk
package require vtkinteraction

# Create the standard renderer, render window
# and interactor
vtkRenderer ren1
vtkRenderWindow renWin
    renWin AddRenderer ren1
vtkRenderWindowInteractor iren
    iren SetRenderWindow renWin

vtkBMPReader reader
   reader SetDataExtent 0 253 0 161 1 184
   reader SetFilePrefix "D:/VTK40/VTKDATA/Data/babybmp/s1"

vtkImageIslandRemoval2D islandRemover
      islandRemover SetAreaThreshold 4
      islandRemover SetIslandValue -1
      islandRemover SetReplaceValue 1.0
      islandRemover SetInput [reader GetOutput];

vtkImageGaussianSmooth  gaussian
     gaussian SetStandardDeviations 1.0 1.0 1.0
     gaussian SetRadiusFactors 1.0 1.0 1.0
     gaussian SetInput [islandRemover GetOutput] 


vtkImageThreshold selectTissue
     selectTissue ThresholdBetween 66.0 255.0
     selectTissue ReplaceInOff
     selectTissue SetOutValue 0.0
     selectTissue SetInput [gaussian GetOutput]

# Create transfer mapping scalar value to opacity
vtkPiecewiseFunction opacityTransferFunction
    opacityTransferFunction AddPoint  66   0.259
    opacityTransferFunction AddPoint  255  1.0

# Create transfer mapping scalar value to color
vtkColorTransferFunction colorTransferFunction
    colorTransferFunction AddRGBPoint      0.0 0.0 0.0 0.0
    colorTransferFunction AddRGBPoint     66.0 0.259 0.259 0.3
    colorTransferFunction AddRGBPoint    255.0 1.0 1.0 0.3

# The property describes how the data will look
vtkVolumeProperty volumeProperty
    volumeProperty SetColor colorTransferFunction
    volumeProperty SetScalarOpacity opacityTransferFunction

# The mapper / ray cast function know how to render the data
vtkVolumeRayCastCompositeFunction  compositeFunction
vtkVolumeRayCastMapper volumeMapper
    volumeMapper SetVolumeRayCastFunction compositeFunction
    volumeMapper SetInput [reader GetOutput]

# The volume holds the mapper and the property and
# can be used to position/orient the volume
vtkVolume volume
    volume SetMapper volumeMapper
    volume SetProperty volumeProperty

ren1 AddVolume volume
renWin Render

proc TkCheckAbort {} {
  set foo [renWin GetEventPending]
  if {$foo != 0} {renWin SetAbortRender 1}
}
renWin SetAbortCheckMethod {TkCheckAbort}

iren SetUserMethod {wm deiconify .vtkInteract}
iren Initialize

wm withdraw .



Thanks a lot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20020423/b3009cf4/attachment.htm>


More information about the vtkusers mailing list