<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 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() 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.<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 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>
<BR>
thanks a lot<BR>
<BR>José<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<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>