[vtkusers] How to display contents of vtkImageData
Elvis Dowson
elvis.dowson at mac.com
Fri Nov 14 10:00:42 EST 2008
Thanks Rob,
That example code worked.
Here is the full program
# This example shows how to initialize and display a blank image using
vtkImageData.
#
#
package require vtk
#
=
=
=
========================================================================
# Create image data
#
=
=
=
========================================================================
vtkImageData imageData
imageData SetScalarTypeToUnsignedChar
imageData SetDimensions 16 16 1
imageData SetOrigin 0.0 0.0 0.0
imageData SetSpacing 1.0 1.0 1.0
imageData AllocateScalars
# Fill image with zeroes
set d 0
for {set i 0} {$i < 16} {incr i} {
for {set p 0} {$p < 16} {incr p} {
imageData SetScalarComponentFromFloat $i $p 0 0 $d
}
}
# Create an image actor to display the image data
vtkImageActor imageActor
imageActor SetInput imageData
#
=
=
=
========================================================================
# Create renderer, render window and add actors to the renderer
#
=
=
=
========================================================================
# Create the RenderWindow, Renderer and both Actors
#
vtkRenderer ren1
vtkRenderWindow renWin
renWin AddRenderer ren1
vtkRenderWindowInteractor iren
iren SetRenderWindow renWin
# Add the actors to the renderer, set the background and size
#
ren1 AddActor imageActor
ren1 SetBackground .1 .2 .4
iren AddObserver UserEvent {wm deiconify .vtkInteract}
iren SetDesiredUpdateRate 5
ren1 ResetCamera
ren1 ResetCameraClippingRange
renWin Render
wm withdraw .
Best regards,
Elvis Dowson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20081114/43ee9562/attachment.htm>
More information about the vtkusers
mailing list