<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>
Hello Shakes <BR>
I was very busy these days and i just tried to run the testing code but i couldn't run it.<BR>
i got this mistake:<BR>
<BR>
File "F:\MisejemplosPython\miVtkImageData3.py", line 24, in ?<BR> blankImage.SetScalarComponentFromFloat(0,1, 1,0, 1.2)<BR>AttributeError: SetScalarComponentFromFloat<BR>
<BR>
this is the code:<BR>
<BR>
dim=256<BR>blankImage=vtkImageData()<BR>blankImage.SetScalarTypeToFloat()<BR>blankImage.SetDimensions(dim ,dim, 1)<BR>blankImage.SetOrigin(0,0,0)<BR>blankImage.AllocateScalars()<BR>print "Components",blankImage.GetNumberOfScalarComponents()<BR>blankImage.SetScalarComponentFromFloat(0,1, 1,0, 1.2)<BR>
<BR>
but when a i changed ScalarType and NumberOfScalar:<BR>
<BR>
blankImage.SetScalarTypeToUnsignedChar()<BR>blankImage.SetNumberOfScalarComponents(4)<BR>
<BR>
i saw this:<BR>
<A href="http://img160.imageshack.us/my.php?image=proof1yo5.jpg">http://img160.imageshack.us/my.php?image=proof1yo5.jpg</A><BR>
<A href="http://img155.imageshack.us/my.php?image=proof2sd3.jpg">http://img155.imageshack.us/my.php?image=proof2sd3.jpg</A><BR>
<BR>
With<BR>
blanking=blankImage.GetPointData().GetScalars()<BR>
blanking.SetComponent(i, 0, 1)<BR>
<BR>
i can paint each cell but only with black and white. I want to paint using RGB<BR>
i am not expert and i need a example please.<BR>
<BR>
thanks in advance.<BR>
Jose<BR>
<BR><BR>> Date: Mon, 10 Dec 2007 10:45:20 +1100<BR>> From: Shekhar.Chandra@sci.monash.edu.au<BR>> Subject: Re: [vtkusers] vtkImageData python<BR>> To: daviddarkzero@hotmail.com<BR>> CC: vtkusers@vtk.org<BR>> <BR>> Hi Jose,<BR>> <BR>> For the C++ API Docs:<BR>> <BR>> virtual float GetScalarComponentAsFloat (int x, int y, int z, int <BR>> component)<BR>> virtual void SetScalarComponentFromFloat (int x, int y, int z, int <BR>> component, float v)<BR>> virtual double GetScalarComponentAsDouble (int x, int y, int z, int <BR>> component)<BR>> virtual void SetScalarComponentFromDouble (int x, int y, int z, int <BR>> component, double v)<BR>> <BR>> Those will do what u want. U can also set the number of scalar <BR>> components and their type. Just check out the Doxygen API Doc. Hope that <BR>> helps.<BR>> <BR>> Cheers<BR>> Shakes<BR>> <BR>> Jose David Pfuturi Huisa wrote:<BR>> > Hello everybody<BR>> > I want to create an image with vtkImagedata, i saw an example using C++ <BR>> > code as follows:<BR>> > int x,y;<BR>> > vtkImageData *image;<BR>> > image=vtkImageData::New();<BR>> > image->SetDimensions(256,256,1);<BR>> > image->SetScalarTypeToFloat();<BR>> > image->AllocateScalars();<BR>> > float *ptr=static_cast<float*>(image->GetScalarPointer());<BR>> > for(y=0;y<256;++y)<BR>> > { for(x=0;x<256;++x)<BR>> > {*ptr++=10.0*sin(0.1*x)*sin(0.1*y);<BR>> > }<BR>> > }<BR>> > vtkImageViewer *viewer=vtkImageViewer::New();<BR>> > viewer->SetInput(image);<BR>> > viewer->SetColorWindow(20);<BR>> > viewer->SetColorLevel(0);<BR>> > viewer->Render();<BR>> > <BR>> > How could i do it using Python? i tried to do it but GetScalarPointer() <BR>> > returns a pointer and in c++ this pointer stores the scalar value each <BR>> > position but on Python i dont know how i can do it.<BR>> > image=vtkImageData()<BR>> > image.SetDimensions(256,256,1)<BR>> > image.SetOrigin(0,0,0)<BR>> > image.SetScalarTypeToUnsignedChar ()<BR>> > image.AllocateScalars ()<BR>> > ptr=data.GetScalarPointer()<BR>> > for y in range(0,256):<BR>> > for x in range(0,256):<BR>> > #?<BR>> > viewer=vtkImageViewer();<BR>> > viewer.SetInput(image);<BR>> > viewer.SetColorWindow(20);<BR>> > viewer.SetColorLevel(0);<BR>> > <BR>> > In *ptr++=10.0*sin(0.1*x)*sin(0.1*y) i suppose that it changes the pixel <BR>> > value, true?<BR>> > if not then, an image has pixels, and this pixels has a RGB value, How <BR>> > could i get this value (each pixel)?<BR>> > <BR>> > thanks a lot<BR>> > <BR>> > José<BR>> > <BR>> > <BR>> > <BR>> > <BR>> > <BR>> > <BR>> > <BR>> > <BR>> > <BR>> > <BR>> > <BR>> > <BR>> > <BR>> > <BR>> > ------------------------------------------------------------------------<BR>> > Tecnología, moda, motor, viajes,…suscríbete a nuestros boletines para <BR>> > estar a la última MSN Newsletters <BR>> > <http://newsletters.msn.com/hm/maintenanceeses.asp?L=ES&C=ES&P=WCMaintenance&Brand=WL&RU=http%3a%2f%2fmail.live.com><BR>> > <BR>> > <BR>> > ------------------------------------------------------------------------<BR>> > <BR>> > _______________________________________________<BR>> > This is the private VTK discussion list. <BR>> > Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ<BR>> > Follow this link to subscribe/unsubscribe:<BR>> > http://www.vtk.org/mailman/listinfo/vtkusers<BR>> <BR><BR><br /><hr />Sigue los principales acontecimientos deportivos en directo. <a href='http://video.msn.com/video.aspx?mkt=es-es' target='_new'>MSN Motor</a></body>
</html>