FW: [vtkusers] vtkImageData python

Jose David Pfuturi Huisa daviddarkzero at hotmail.com
Tue Dec 18 12:49:43 EST 2007


Hello Shakes 
I was very busy these days and i just tried to run the testing code but i couldn't run it.
i got this mistake:
 
File "F:\MisejemplosPython\miVtkImageData3.py", line 24, in ?    blankImage.SetScalarComponentFromFloat(0,1, 1,0, 1.2)AttributeError: SetScalarComponentFromFloat
 
this is the code:
 
dim=256blankImage=vtkImageData()blankImage.SetScalarTypeToFloat()blankImage.SetDimensions(dim ,dim, 1)blankImage.SetOrigin(0,0,0)blankImage.AllocateScalars()print "Components",blankImage.GetNumberOfScalarComponents()blankImage.SetScalarComponentFromFloat(0,1, 1,0, 1.2)
 
but when a i changed ScalarType and NumberOfScalar:
 
blankImage.SetScalarTypeToUnsignedChar()blankImage.SetNumberOfScalarComponents(4)
 
i saw this:
http://img160.imageshack.us/my.php?image=proof1yo5.jpg
http://img155.imageshack.us/my.php?image=proof2sd3.jpg
 
With
blanking=blankImage.GetPointData().GetScalars()
blanking.SetComponent(i, 0, 1)
 
i can paint each cell but only with black and white. I want to paint using RGB
i am not expert and i need a example please.
 
thanks in advance.
Jose
> Date: Mon, 10 Dec 2007 10:45:20 +1100> From: Shekhar.Chandra at sci.monash.edu.au> Subject: Re: [vtkusers] vtkImageData python> To: daviddarkzero at hotmail.com> CC: vtkusers at vtk.org> > Hi Jose,> > For the C++ API Docs:> > virtual float GetScalarComponentAsFloat (int x, int y, int z, int > component)> virtual void SetScalarComponentFromFloat (int x, int y, int z, int > component, float v)> virtual double GetScalarComponentAsDouble (int x, int y, int z, int > component)> virtual void SetScalarComponentFromDouble (int x, int y, int z, int > component, double v)> > Those will do what u want. U can also set the number of scalar > components and their type. Just check out the Doxygen API Doc. Hope that > helps.> > Cheers> Shakes> > Jose David Pfuturi Huisa wrote:> > 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 MSN Newsletters > > <http://newsletters.msn.com/hm/maintenanceeses.asp?L=ES&C=ES&P=WCMaintenance&Brand=WL&RU=http%3a%2f%2fmail.live.com>> > > > > > ------------------------------------------------------------------------> > > > _______________________________________________> > 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> 
_________________________________________________________________
La vida de los famosos al desnudo en MSN Entretenimiento
http://entretenimiento.es.msn.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20071218/e6441b7f/attachment.htm>


More information about the vtkusers mailing list