[vtkusers] Creating a volume from Tiff-files
    Till Bentz 
    till at onyxus.de
       
    Tue Oct  4 07:12:02 EDT 2005
    
    
  
Hi!
I try to create a volume from a bunch of TIFF files. I get a render-
window and and kind of a volume, too. The problem is that the volume is
more like a "cloud of points". The second problem is that the volume
covers only part of the pictures although "puts" gives the right values.
Can anyone help me with this problem?
The TIFF pictures are grayscale files converted with ImageMagick.
I'm using vtk 4.2 with tcl/tk 8.4
 
-----------------
package require vtk
package require vtkinteraction
vtkRenderer ren1
vtkRenderWindow renWin
    renWin AddRenderer ren1
    renWin SetSize 800 800
vtkRenderWindowInteractor iren
    iren SetRenderWindow renWin
#create the Reader for the TIFF data
vtkImageReader2 rRed
  rRed SetDataByteOrderToLittleEndian
  rRed SetDataScalarTypeToUnsignedChar
  rRed SetDataExtent 0 647 0 647 0 22
  rRed SetFilePrefix "/home/kublai/projects/pics/green/green_arc_homer_st"
  rRed SetDataSpacing 0.5 0.5 1.0
rRed Update
scan [[rRed GetOutput] GetWholeExtent] "%d %d %d %d %d %d" \
        xMin xMax yMin yMax zMin zMax
puts "xMin=$xMin, xMax=$xMax, yMin=$yMin, yMax=$yMax, zMin=$zMin, zMax=$zMax"
# Create transfer mapping scalar value to opacity
vtkPiecewiseFunction opacityTransferFunction
    opacityTransferFunction AddPoint  10   0.0
    opacityTransferFunction AddPoint  255  0.8
#create the gradiant opacity transfer function
vtkPiecewiseFunction gtFun
  gtFun AddPoint 0 0
  gtFun AddPoint 5 0
  gtFun AddPoint 10 1
  gtFun AddPoint 255 1
# The property describes how the data will look
vtkVolumeProperty volumePropertyRed
    volumePropertyRed SetScalarOpacity opacityTransferFunction
    volumePropertyRed SetInterpolationTypeToLinear
    volumePropertyRed SetGradientOpacity gtFun
    volumePropertyRed ShadeOn
vtkVolumeRayCastCompositeFunction compositeFunction
vtkVolumeRayCastMIPFunction mipFunction
vtkVolumeRayCastIsosurfaceFunction isoFunction
vtkVolumeRayCastMapper volumeMapper
  volumeMapper SetInput [rRed GetOutput]
  volumeMapper SetVolumeRayCastFunction compositeFunction
  volumeMapper SetSampleDistance 0.5
# The volume holds the mapper and the property and
# can be used to position/orient the volume
vtkVolume volumeRed
    volumeRed SetMapper volumeMapper
    volumeRed SetProperty volumePropertyRed
ren1 AddVolume volumeRed
ren1 SetBackground 1.0 1.0 1.0
renWin Render
proc TkCheckAbort {} {
  set foo [renWin GetEventPending]
  if {$foo != 0} {renWin SetAbortRender 1}
}
renWin AddObserver AbortCheckEvent {TkCheckAbort}
vtkInteractorStyleTrackballCamera style
iren SetInteractorStyle style
iren AddObserver UserEvent {wm deiconify .vtkInteract}
iren Initialize
wm withdraw .
----------------------
Thanks
Till
    
    
More information about the vtkusers
mailing list