[vtkusers] volume rendering (HELP)

Pan, Tony C (Research) tpan at crd.ge.com
Tue Jun 4 10:19:26 EDT 2002


colorTransferFunction AddRGBPoint takes RGB color specification as float between 0.0 and 1.0

So your code would look like 

	colorTransferFunction AddRGBPoint    128 0.3 0 0
	colorTransferFunction AddRGBPoint    255 0 0 0.8

which gives a dark red for scalar value of 128, a bright blue at scalar value of 255, and shades of
purple (linearly interpolated in RGB color space) in between.

See http://public.kitware.com/VTK/doc/nightly/html/classvtkColorTransferFunction.html for api spec
and examples.

Tony



-----Original Message-----
From: vtk at le.isac.cnr.it [mailto:vtk at le.isac.cnr.it]
Sent: Tuesday, June 04, 2002 4:57 AM
To: vtkusers at public.kitware.com
Subject: [vtkusers] volume rendering (HELP)


Hi..
I work with VTK 4 and tcl/tk on workstation Linux.
What can I do to configure this function to visualize many different color in volume rendering??

vtkColorTransferFunction colorTransferFunction
    colorTransferFunction AddRGBPoint      0 1 0 0
    colorTransferFunction AddRGBPoint     64 2 0 0
    colorTransferFunction AddRGBPoint    128 3 0 0
    colorTransferFunction AddRGBPoint    255 4 0 0
    colorTransferFunction AddRGBPoint    0 0 0 1
    colorTransferFunction AddRGBPoint   64 0 0 2
    colorTransferFunction AddRGBPoint  128 0 0 3
    colorTransferFunction AddRGBPoint  192 0 0 4
    colorTransferFunction AddRGBPoint  255 0 0 5
    colorTransferFunction AddRGBPoint     0 0 1 0 
    colorTransferFunction AddRGBPoint   128 0 2 0 
    colorTransferFunction AddRGBPoint   192 0 3 0 
    colorTransferFunction AddRGBPoint   255 0 4 0 




                *****************************



The source code is:



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


# Create the reader for the data
vtkStructuredPointsReader reader
    reader SetFileName "binHeart.vtk"


# Create transfer mapping scalar value to opacity
vtkPiecewiseFunction opacityTransferFunction
    opacityTransferFunction AddPoint  20   0.0
    opacityTransferFunction AddPoint  255  0.2


vtkColorTransferFunction colorTransferFunction
    colorTransferFunction AddRGBPoint      0 1 0 0
    colorTransferFunction AddRGBPoint     64 2 0 0
    colorTransferFunction AddRGBPoint    128 3 0 0
    colorTransferFunction AddRGBPoint    255 4 0 0
    colorTransferFunction AddRGBPoint    0 0 0 1
    colorTransferFunction AddRGBPoint   64 0 0 2
    colorTransferFunction AddRGBPoint  128 0 0 3
    colorTransferFunction AddRGBPoint  192 0 0 4
    colorTransferFunction AddRGBPoint  255 0 0 5
    colorTransferFunction AddRGBPoint     0 0 1 0 
    colorTransferFunction AddRGBPoint   128 0 2 0 
    colorTransferFunction AddRGBPoint   192 0 3 0 
    colorTransferFunction AddRGBPoint   255 0 4 0 




# 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 SetBackground 0 0 0


ren1 AddVolume volume
renWin Render



wm withdraw .




_______________________________________________
This is the private VTK discussion list. 
Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers



More information about the vtkusers mailing list