<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>
&nbsp;<BR>
File "F:\MisejemplosPython\miVtkImageData3.py", line 24, in ?<BR>&nbsp;&nbsp;&nbsp; blankImage.SetScalarComponentFromFloat(0,1, 1,0, 1.2)<BR>AttributeError: SetScalarComponentFromFloat<BR>
&nbsp;<BR>
this is the code:<BR>
&nbsp;<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>
&nbsp;<BR>
but when a i changed&nbsp;ScalarType and NumberOfScalar:<BR>
&nbsp;<BR>
blankImage.SetScalarTypeToUnsignedChar()<BR>blankImage.SetNumberOfScalarComponents(4)<BR>
&nbsp;<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>
&nbsp;<BR>
With<BR>
blanking=blankImage.GetPointData().GetScalars()<BR>
blanking.SetComponent(i, 0, 1)<BR>
&nbsp;<BR>
i&nbsp;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>
&nbsp;<BR>
thanks in advance.<BR>
Jose<BR>
<BR><BR>&gt; Date: Mon, 10 Dec 2007 10:45:20 +1100<BR>&gt; From: Shekhar.Chandra@sci.monash.edu.au<BR>&gt; Subject: Re: [vtkusers] vtkImageData python<BR>&gt; To: daviddarkzero@hotmail.com<BR>&gt; CC: vtkusers@vtk.org<BR>&gt; <BR>&gt; Hi Jose,<BR>&gt; <BR>&gt; For the C++ API Docs:<BR>&gt; <BR>&gt; virtual float GetScalarComponentAsFloat (int x, int y, int z, int <BR>&gt; component)<BR>&gt; virtual void SetScalarComponentFromFloat (int x, int y, int z, int <BR>&gt; component, float v)<BR>&gt; virtual double GetScalarComponentAsDouble (int x, int y, int z, int <BR>&gt; component)<BR>&gt; virtual void SetScalarComponentFromDouble (int x, int y, int z, int <BR>&gt; component, double v)<BR>&gt; <BR>&gt; Those will do what u want. U can also set the number of scalar <BR>&gt; components and their type. Just check out the Doxygen API Doc. Hope that <BR>&gt; helps.<BR>&gt; <BR>&gt; Cheers<BR>&gt; Shakes<BR>&gt; <BR>&gt; Jose David Pfuturi Huisa wrote:<BR>&gt; &gt; Hello everybody<BR>&gt; &gt; I want to create an image with vtkImagedata, i saw an example using C++ <BR>&gt; &gt; code as follows:<BR>&gt; &gt; int x,y;<BR>&gt; &gt; vtkImageData *image;<BR>&gt; &gt; image=vtkImageData::New();<BR>&gt; &gt; image-&gt;SetDimensions(256,256,1);<BR>&gt; &gt; image-&gt;SetScalarTypeToFloat();<BR>&gt; &gt; image-&gt;AllocateScalars();<BR>&gt; &gt; float *ptr=static_cast&lt;float*&gt;(image-&gt;GetScalarPointer());<BR>&gt; &gt; for(y=0;y&lt;256;++y)<BR>&gt; &gt; { for(x=0;x&lt;256;++x)<BR>&gt; &gt; {*ptr++=10.0*sin(0.1*x)*sin(0.1*y);<BR>&gt; &gt; }<BR>&gt; &gt; }<BR>&gt; &gt; vtkImageViewer *viewer=vtkImageViewer::New();<BR>&gt; &gt; viewer-&gt;SetInput(image);<BR>&gt; &gt; viewer-&gt;SetColorWindow(20);<BR>&gt; &gt; viewer-&gt;SetColorLevel(0);<BR>&gt; &gt; viewer-&gt;Render();<BR>&gt; &gt; <BR>&gt; &gt; How could i do it using Python? i tried to do it but GetScalarPointer() <BR>&gt; &gt; returns a pointer and in c++ this pointer stores the scalar value each <BR>&gt; &gt; position but on Python i dont know how i can do it.<BR>&gt; &gt; image=vtkImageData()<BR>&gt; &gt; image.SetDimensions(256,256,1)<BR>&gt; &gt; image.SetOrigin(0,0,0)<BR>&gt; &gt; image.SetScalarTypeToUnsignedChar ()<BR>&gt; &gt; image.AllocateScalars ()<BR>&gt; &gt; ptr=data.GetScalarPointer()<BR>&gt; &gt; for y in range(0,256):<BR>&gt; &gt; for x in range(0,256):<BR>&gt; &gt; #?<BR>&gt; &gt; viewer=vtkImageViewer();<BR>&gt; &gt; viewer.SetInput(image);<BR>&gt; &gt; viewer.SetColorWindow(20);<BR>&gt; &gt; viewer.SetColorLevel(0);<BR>&gt; &gt; <BR>&gt; &gt; In *ptr++=10.0*sin(0.1*x)*sin(0.1*y) i suppose that it changes the pixel <BR>&gt; &gt; value, true?<BR>&gt; &gt; if not then, an image has pixels, and this pixels has a RGB value, How <BR>&gt; &gt; could i get this value (each pixel)?<BR>&gt; &gt; <BR>&gt; &gt; thanks a lot<BR>&gt; &gt; <BR>&gt; &gt; José<BR>&gt; &gt; <BR>&gt; &gt; <BR>&gt; &gt; <BR>&gt; &gt; <BR>&gt; &gt; <BR>&gt; &gt; <BR>&gt; &gt; <BR>&gt; &gt; <BR>&gt; &gt; <BR>&gt; &gt; <BR>&gt; &gt; <BR>&gt; &gt; <BR>&gt; &gt; <BR>&gt; &gt; <BR>&gt; &gt; ------------------------------------------------------------------------<BR>&gt; &gt; Tecnología, moda, motor, viajes,…suscríbete a nuestros boletines para <BR>&gt; &gt; estar a la última MSN Newsletters <BR>&gt; &gt; &lt;http://newsletters.msn.com/hm/maintenanceeses.asp?L=ES&amp;C=ES&amp;P=WCMaintenance&amp;Brand=WL&amp;RU=http%3a%2f%2fmail.live.com&gt;<BR>&gt; &gt; <BR>&gt; &gt; <BR>&gt; &gt; ------------------------------------------------------------------------<BR>&gt; &gt; <BR>&gt; &gt; _______________________________________________<BR>&gt; &gt; This is the private VTK discussion list. <BR>&gt; &gt; Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ<BR>&gt; &gt; Follow this link to subscribe/unsubscribe:<BR>&gt; &gt; http://www.vtk.org/mailman/listinfo/vtkusers<BR>&gt; <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>