[vtkusers] vtkImageData python
Jose David Pfuturi Huisa
daviddarkzero at hotmail.com
Sun Dec 9 16:37:59 EST 2007
Hello everybody
I want to create an image with vtkImagedata, i saw an example using C++ code as follows:
int x,y;vtkImageData *image;image=vtkImageData::New();image->SetDimensions(256,256,1);image->SetScalarTypeToFloat();image->AllocateScalars();float *ptr=static_cast<float*>(image->GetScalarPointer());for(y=0;y<256;++y){ for(x=0;x<256;++x) {*ptr++=10.0*sin(0.1*x)*sin(0.1*y);
}}
vtkImageViewer *viewer=vtkImageViewer::New();viewer->SetInput(image);viewer->SetColorWindow(20);viewer->SetColorLevel(0);viewer->Render();
How could i do it using Python? i tried to do it but GetScalarPointer() returns a pointer and in c++ this pointer stores the scalar value each position but on Python i dont know how i can do it.
image=vtkImageData()image.SetDimensions(256,256,1)image.SetOrigin(0,0,0)image.SetScalarTypeToUnsignedChar ()image.AllocateScalars ()
ptr=data.GetScalarPointer()
for y in range(0,256): for x in range(0,256): #?viewer=vtkImageViewer();viewer.SetInput(image);viewer.SetColorWindow(20);viewer.SetColorLevel(0);
In *ptr++=10.0*sin(0.1*x)*sin(0.1*y) i suppose that it changes the pixel value, true?
if not then, an image has pixels, and this pixels has a RGB value, How could i get this value (each pixel)?
thanks a lot
José
_________________________________________________________________
Tecnología, moda, motor, viajes,…suscríbete a nuestros boletines para estar a la última
http://newsletters.msn.com/hm/maintenanceeses.asp?L=ES&C=ES&P=WCMaintenance&Brand=WL&RU=http%3a%2f%2fmail.live.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20071209/5eefb4b0/attachment.htm>
More information about the vtkusers
mailing list