You have to remember to reply to the vtk users board as well, don&#39;t direct the emails to just me.<br><br>How big is your render window, you&#39;re only sampling the first 1041 / 3 pixels there, and I wouldn&#39;t be surprised if they were all black. You should also verify that the image data is 3 component unsigned char. I would also make sure that your png actually contains something by just writing it to disk.<br>
<br>Mark<br><br><br><div class="gmail_quote">On Thu, Apr 24, 2008 at 1:15 PM,  &lt;<a href="mailto:yenanqu@scs.fsu.edu">yenanqu@scs.fsu.edu</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Here is my code:<br>
======================================<div class="Ih2E3d"><br>
renWin-&gt;Render();<br>
vtkWindowToImageFilter * w2i = vtkWindowToImageFilter::New();<br>
vtkPNGWriter * writer = vtkPNGWriter::New();<br>
w2i-&gt;SetInput( renWin );<br></div>
writer-&gt;SetInput( w2i-&gt;GetOutput() );<br>
w2i-&gt;Update();<br>
vtkImageData * id = w2i-&gt;GetOutput();<br>
id-&gt;Update();<br>
//int* siz = id-&gt;GetDimensions();<br>
//unsigned long ms = id-&gt;GetActualMemorySize();<br>
//int ms1 = id-&gt;GetScalarSize();<br>
unsigned char* pPix;<br>
pPix = (unsigned char*)id-&gt;GetScalarPointer();<br>
<br>
for(int ee=0;ee&lt;1041;ee++){<br>
 &nbsp; int pp = pPix[ee];<br>
 &nbsp; cout&lt;&lt;&quot; &quot;&lt;&lt;pp;<br>
}<br>
===============================================<br>
The thing I can be sure is there is no problem with id (vtkImageData)<div><div></div><div class="Wj3C7c"><br>
<br>
Yenan<br>
<br>
<br>
<br>
Quoting Mark Wyszomierski &lt;<a href="mailto:markww@gmail.com" target="_blank">markww@gmail.com</a>&gt;:<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Are you sure you actually set any of the RGB components in the first place?<br>
You could just be allocating the image array, all elements are set to zero,<br>
and you&#39;ll just get a zero for every element you access.<br>
<br>
Mark<br>
<br>
On Thu, Apr 24, 2008 at 12:49 PM, &lt;<a href="mailto:yenanqu@scs.fsu.edu" target="_blank">yenanqu@scs.fsu.edu</a>&gt; wrote:<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
when I do<br>
&quot;unsigned char *pVtkPix = (unsigned char *)pImgData-&gt;GetScalarPointer();&quot;<br>
it doesn&#39;t seem to get the scarlar pointer, I have already do all the<br>
update thing before this, and I also could get dimensions from pImgData. but<br>
when I output all the RGB value with your method, they are all 0.<br>
this stuff really kills me~~~<br>
<br>
<br>
Yenan<br>
<br>
<br>
Quoting Mark Wyszomierski &lt;<a href="mailto:markww@gmail.com" target="_blank">markww@gmail.com</a>&gt;:<br>
<br>
&nbsp;I think the RGB pixel data is usually allocated like:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
 &nbsp; RGBRGBRGB etc....<br>
<br>
so you have numPixels * 3 actual elements in your image data array.<br>
<br>
You get a pixel pointer as usual and cast it to (unsigned char*):<br>
<br>
// Get a pointer to the actual pixel data.<br>
unsigned char *pVtkPix = (unsigned char *)pImgData-&gt;GetScalarPointer();<br>
<br>
// These are the r,g and b values for the first pixel:<br>
int rr &nbsp;= pVtkPix[0];<br>
int gg = pVtkPix[1];<br>
int bb = pVtkPix[2];<br>
<br>
// For the second pixel:<br>
rr &nbsp;= pVtkPix[3];<br>
gg = pVtkPix[4];<br>
bb = pVtkPix[5];<br>
<br>
and so on. Make sure you don&#39;t have RGBA data, if you do, then you just<br>
have<br>
an extra index per pixel which is the alpha component. Let me know if that<br>
helps,<br>
<br>
Mark<br>
<br>
<br>
On Wed, Apr 23, 2008 at 7:08 PM, &lt;<a href="mailto:yenanqu@scs.fsu.edu" target="_blank">yenanqu@scs.fsu.edu</a>&gt; wrote:<br>
<br>
&nbsp;Hi, Mark, I did have the data that is three component. Your example only<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
shows how to get pixel data that is one component which I never got in my<br>
code before. Do you have any idea how to retrieve this three component<br>
data?<br>
I have try bunch of methods, but none of them is working. any help will<br>
be<br>
greatly appreciated.<br>
<br>
Yenan<br>
<br>
Quoting Mark Wyszomierski &lt;<a href="mailto:markww@gmail.com" target="_blank">markww@gmail.com</a>&gt;:<br>
<br>
&nbsp;Hi,<br>
&gt;<br>
&gt; It&#39;s definitely possible to get the scalar value from a vtkImageData<br>
&gt; object. You need to know the type of data your object is stored in<br>
&gt; though, for example you&#39;ll have difficulty getting the scalar value if<br>
&gt; your data is three component RGB and you&#39;re trying to get a single<br>
&gt; pixel scalar pixel value.<br>
&gt;<br>
&gt; I have an example of getting the pixel value that the mouse moves over<br>
&gt; in an image here:<br>
&gt;<br>
&gt;<br>
&gt;<br>
<a href="http://devsample.org/index.php?option=com_content&amp;task=view&amp;id=48&amp;Itemid=27" target="_blank">http://devsample.org/index.php?option=com_content&amp;task=view&amp;id=48&amp;Itemid=27</a><br>
&gt;<br>
&gt; which may help.<br>
&gt;<br>
&gt; Mark<br>
&gt;<br>
&gt;<br>
&gt; On Thu, Mar 27, 2008 at 1:37 PM, &nbsp;&lt;<a href="mailto:yenanqu@scs.fsu.edu" target="_blank">yenanqu@scs.fsu.edu</a>&gt; wrote:<br>
&gt;<br>
&gt; &gt; Hi, all,<br>
&gt; &gt; I found bunch of the VTK methods to retrieve pixel data from vtk<br>
&gt; &gt; object, such as<br>
&gt; &gt; GetPixelData, GetRGBACharPixelData, etc, but none of them is working,<br>
&gt; &gt; Does anyone know how to get pixel data from VTK object? Thanks in<br>
&gt; &gt; advance.<br>
&gt; &gt;<br>
&gt; &gt; Yenan<br>
&gt; &gt;<br>
&gt; &gt; ----------------------------------------------------------------<br>
&gt; &gt; This message was sent using IMP, the Internet Messaging Program.<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; --<br>
&gt; &gt; This message has been scanned for viruses and<br>
&gt; &gt; dangerous content by MailScanner, and is<br>
&gt; &gt; believed to be clean.<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:<br>
&gt; &gt; <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
&gt; &gt; Follow this link to subscribe/unsubscribe:<br>
&gt; &gt; <a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; --<br>
&gt; This message has been scanned for viruses and<br>
&gt; dangerous content by MailScanner, and is<br>
&gt; believed to be clean.<br>
&gt;<br>
&gt;<br>
&gt;<br>
<br>
<br>
----------------------------------------------------------------<br>
This message was sent using IMP, the Internet Messaging Program.<br>
<br>
<br>
--<br>
This message has been scanned for viruses and<br>
dangerous content by MailScanner, and is<br>
believed to be clean.<br>
<br>
<br>
<br>
</blockquote>
--<br>
This message has been scanned for viruses and<br>
dangerous content by MailScanner, and is<br>
believed to be clean.<br>
<br>
<br>
<br>
</blockquote>
<br>
<br>
----------------------------------------------------------------<br>
This message was sent using IMP, the Internet Messaging Program.<br>
<br>
<br>
--<br>
This message has been scanned for viruses and<br>
dangerous content by MailScanner, and is<br>
believed to be clean.<br>
<br>
<br>
</blockquote>
<br>
--<br>
This message has been scanned for viruses and<br>
dangerous content by MailScanner, and is<br>
believed to be clean.<br>
<br>
<br>
</blockquote>
<br>
<br>
<br>
----------------------------------------------------------------<br>
This message was sent using IMP, the Internet Messaging Program.<br>
<br>
<br>
-- <br>
This message has been scanned for viruses and<br>
dangerous content by MailScanner, and is<br>
believed to be clean.<br>
<br>
</div></div></blockquote></div><br>