Are you sure you actually set any of the RGB components in the first place? You could just be allocating the image array, all elements are set to zero, and you'll just get a zero for every element you access.<br><br>Mark<br>
<br><div class="gmail_quote">On Thu, Apr 24, 2008 at 12:49 PM, <<a href="mailto:yenanqu@scs.fsu.edu">yenanqu@scs.fsu.edu</a>> wrote:<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<div class="Ih2E3d"><br>
"unsigned char *pVtkPix = (unsigned char *)pImgData->GetScalarPointer();"<br></div>
it doesn't seem to get the scarlar pointer, I have already do all the update thing before this, and I also could get dimensions from pImgData. but when I output all the RGB value with your method, they are all 0.<br>
this stuff really kills me~~~<div><div></div><div class="Wj3C7c"><br>
<br>
Yenan<br>
<br>
<br>
Quoting Mark Wyszomierski <<a href="mailto:markww@gmail.com" target="_blank">markww@gmail.com</a>>:<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I think the RGB pixel data is usually allocated like:<br>
<br>
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->GetScalarPointer();<br>
<br>
// These are the r,g and b values for the first pixel:<br>
int rr = pVtkPix[0];<br>
int gg = pVtkPix[1];<br>
int bb = pVtkPix[2];<br>
<br>
// For the second pixel:<br>
rr = pVtkPix[3];<br>
gg = pVtkPix[4];<br>
bb = pVtkPix[5];<br>
<br>
and so on. Make sure you don't have RGBA data, if you do, then you just 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, <<a href="mailto:yenanqu@scs.fsu.edu" target="_blank">yenanqu@scs.fsu.edu</a>> 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;">
Hi, Mark, I did have the data that is three component. Your example only<br>
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 data?<br>
I have try bunch of methods, but none of them is working. any help will be<br>
greatly appreciated.<br>
<br>
Yenan<br>
<br>
Quoting Mark Wyszomierski <<a href="mailto:markww@gmail.com" target="_blank">markww@gmail.com</a>>:<br>
<br>
Hi,<br>
><br>
> It's definitely possible to get the scalar value from a vtkImageData<br>
> object. You need to know the type of data your object is stored in<br>
> though, for example you'll have difficulty getting the scalar value if<br>
> your data is three component RGB and you're trying to get a single<br>
> pixel scalar pixel value.<br>
><br>
> I have an example of getting the pixel value that the mouse moves over<br>
> in an image here:<br>
><br>
><br>
> <a href="http://devsample.org/index.php?option=com_content&task=view&id=48&Itemid=27" target="_blank">http://devsample.org/index.php?option=com_content&task=view&id=48&Itemid=27</a><br>
><br>
> which may help.<br>
><br>
> Mark<br>
><br>
><br>
> On Thu, Mar 27, 2008 at 1:37 PM, <<a href="mailto:yenanqu@scs.fsu.edu" target="_blank">yenanqu@scs.fsu.edu</a>> wrote:<br>
><br>
> > Hi, all,<br>
> > I found bunch of the VTK methods to retrieve pixel data from vtk<br>
> > object, such as<br>
> > GetPixelData, GetRGBACharPixelData, etc, but none of them is working,<br>
> > Does anyone know how to get pixel data from VTK object? Thanks in<br>
> > advance.<br>
> ><br>
> > Yenan<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>
> > This is the private VTK discussion list.<br>
> > Please keep messages on-topic. Check the FAQ at:<br>
> > <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
> > Follow this link to subscribe/unsubscribe:<br>
> > <a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><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>
<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>