<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>
Hello everybody<BR>
I want to create an image with vtkImagedata, i saw an example using C++ code&nbsp;as follows:<BR>
int x,y;<BR>vtkImageData *image;<BR>image=vtkImageData::New();<BR>image-&gt;SetDimensions(256,256,1);<BR>image-&gt;SetScalarTypeToFloat();<BR>image-&gt;AllocateScalars();<BR>float *ptr=static_cast&lt;float*&gt;(image-&gt;GetScalarPointer());<BR>for(y=0;y&lt;256;++y)<BR>{&nbsp;&nbsp; for(x=0;x&lt;256;++x)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {*ptr++=10.0*sin(0.1*x)*sin(0.1*y);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>}<BR>
vtkImageViewer *viewer=vtkImageViewer::New();<BR>viewer-&gt;SetInput(image);<BR>viewer-&gt;SetColorWindow(20);<BR>viewer-&gt;SetColorLevel(0);<BR>viewer-&gt;Render();<BR>
&nbsp;<BR>
How could i do it using Python? i tried to do it but GetScalarPointer() returns a pointer and in c++&nbsp;this pointer stores the scalar value each 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>&nbsp;&nbsp;&nbsp; for x in range(0,256):<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#?<BR>viewer=vtkImageViewer();<BR>viewer.SetInput(image);<BR>viewer.SetColorWindow(20);<BR>viewer.SetColorLevel(0);<BR>
&nbsp;<BR>
In *ptr++=10.0*sin(0.1*x)*sin(0.1*y) i suppose that it changes the pixel value, true?<BR>
if not then, an image has pixels, and this pixels has a RGB value, How could i get this value (each pixel)?<BR>
&nbsp;<BR>
thanks a lot<BR>
<BR>José<BR>
&nbsp;<BR>
&nbsp;<BR>
&nbsp;<BR>
&nbsp;<BR>
&nbsp;<BR>
&nbsp;<BR>
&nbsp;<BR>
&nbsp;<BR>
&nbsp;<BR>
&nbsp;<BR>
&nbsp;<BR>
&nbsp;<BR>
&nbsp;<BR><br /><hr />Tecnología, moda, motor, viajes,…suscríbete a nuestros boletines para estar a la última <a href='http://newsletters.msn.com/hm/maintenanceeses.asp?L=ES&C=ES&P=WCMaintenance&Brand=WL&RU=http%3a%2f%2fmail.live.com' target='_new'>MSN Newsletters</a></body>
</html>