[vtkusers] Help creating a vtkImageData object using Python

Pieper, Chris cpieper at kcc.com
Fri Sep 9 14:44:04 EDT 2005


I am a beginner vtk user and would like to generate a vtkImageData
object using Python code.  I have the data that I want to insert into
the object available as Python objects, but don't know how to insert
them into the vtkImageData object.  I saw something in the archives
about using vtkImageImport to do this, but I don't understand the
implementation...

I'm starting with an example from the user's guide:

#! /usr/local/bin/vtkpython
import vtk

NL=Na=Nb=10

size=[NL,Na,Nb]
id=vtk.vtkImageData()
id.SetDimensions(NL,Na,Nb)
id.SetScalarTypeToUnsignedShort()
id.SetNumberOfScalarComponents(1)
id.AllocateScalars()


This much  works, but I don't know how to insert the scalars... The
example uses a C++ pointer to do this, can it be done within Python?

Also, my image data is a structured volume with RGB values at each
location.  Since the space represents different colors (I'm visualizing
colors), each location has a unique RGB value.  Can I use a 3 component
scalar value at each volume coordinate or do I need to create a LUT?

Thanks for any help you may offer.  I apologize if my terminology
doesn't make sense...  

Chris

------------------------------------------------------------------------------
This e-mail is intended for the use of the addressee(s) only and may contain privileged, confidential, or proprietary information that is exempt from disclosure under law.  If you have received this message in error, please inform us promptly by reply e-mail, then delete the e-mail and destroy any printed copy.   Thank you.
==============================================================================



More information about the vtkusers mailing list