[vtkusers] How to make a projection from 3D data?

Hugo Gratama van Andel h.a.gratamavanandel at amc.uva.nl
Wed Jan 25 02:57:45 EST 2006


Hello LM,

If you mean Maximum Intensity Projection I have some code that might 
help you. It is derived from some example TCL-scripts and it gives you a 
  renderwindow in which you can interact with the data and so choose the 
direction of the MIP. Finding code for capturing the 2D output of the 
window should be easy. I used the code below on some CT-images 
(raw-imagedata), you should set all the dimensions yourself.
gr. Hugo

------mip.tcl--------
package require vtk
package require vtkinteraction

# Create the renderer, the render window, and the interactor. The
# renderer draws into the render window, the interactor enables
# keyboard-based interaction with the scene.
vtkRenderer aRenderer
vtkRenderWindow renWin
renWin AddRenderer aRenderer
vtkRenderWindowInteractor iren

vtkInteractorStyleTrackballCamera aTrackBallCamera
iren SetInteractorStyle aTrackBallCamera
iren SetRenderWindow renWin

vtkImageReader reader
reader SetDataByteOrderToLittleEndian
reader SetDataScalarTypeToUnsignedShort
reader SetDataExtent 0 511 0 511 0 373
reader SetDataSpacing 0.29 0.29 0.5
reader SetFileDimensionality 3
reader SetFileName "C:/temp/patient.raw"

# Adding the volume renderer (ray caster)
vtkPiecewiseFunction opacityTransferFunction
opacityTransferFunction AddPoint 1100 0
opacityTransferFunction AddPoint 1500 1.0

vtkColorTransferFunction colorTransferFunction
colorTransferFunction AddRGBPoint 0.0 0.0 0.0 0.0
colorTransferFunction AddRGBPoint 255.0 1.0 1.0 1.0

vtkVolumeProperty volumeProperty
volumeProperty SetColor colorTransferFunction
volumeProperty SetScalarOpacity opacityTransferFunction

vtkVolumeRayCastMIPFunction MIP
vtkVolumeRayCastMapper volumeMapper
volumeMapper SetVolumeRayCastFunction MIP
volumeMapper SetInputConnection [reader GetOutputPort]

vtkVolume volume
volume SetMapper volumeMapper
volume SetProperty volumeProperty
volume VisibilityOn
volume Update

# Bounding box.
vtkOutlineFilter outlineData
outlineData SetInputConnection [reader GetOutputPort]
vtkPolyDataMapper mapOutline
mapOutline SetInputConnection [outlineData GetOutputPort]
vtkActor outline
outline SetMapper mapOutline
[outline GetProperty] SetColor 0 1 0

# Actors are added to the renderer.
aRenderer AddActor outline
aRenderer AddVolume volume

vtkCamera aCamera
aRenderer SetActiveCamera aCamera

# Setting the color and size of the renderwindow,
#initializing the camera position
aCamera SetViewUp 0 0 -1
aCamera SetPosition -2 -2 -2
aCamera SetFocalPoint 0 0 0
aCamera ComputeViewPlaneNormal
aRenderer ResetCamera
aRenderer ResetCameraClippingRange
aRenderer SetBackground 0.2 0.2 0.2
renWin SetSize 640 480

# Set up a callback (using command/observer) to bring up the Tcl
# command GUI when the keypress-u (UserEvent) key is pressed.
iren AddObserver UserEvent {wm deiconify .vtkInteract}

# Here we go!
iren Initialize
#renWin Render
#iren Start
wm withdraw .
---- end mip.tcl-----

LM wrote:
> Hi all..
> Please could any one tell me how to get a *2D projection* from a 3D 
> Image Data..
> As I would like to represent projections in each x-y plane, y-zplane and 
> x-z plane..
> at least i need a class name..
> thanks in advance
> 
> ------------------------------------------------------------------------
> Yahoo! Photos
> Got holiday prints? See all the ways 
> <http://us.rd.yahoo.com/mail_us/taglines/holidayprints/*http://pa.yahoo.com/*http://us.rd.yahoo.com/mail_us/taglines/photos/evt=38089/*http://pg.photos.yahoo.com/ph//print_splash> 
> to get quality prints in your hands ASAP.
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> This is the private VTK discussion list. 
> Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers

-- 
Hugo Gratama van Andel



More information about the vtkusers mailing list