PDA

View Full Version : Is it possible to get the value of every pixel?



wcx730916119
11-27-2015, 02:25 AM
I am really a beginner and my question is:

In openGL, is it possible to get the data of every pixel?
I want to get what every pixel means in the image (e,g, a tree, a house or sky) and the RGB value of that pixel.
If there is such a way to do this, how?

Thanks very much.

GClements
11-27-2015, 07:57 AM
glReadPixels() can be used to read the contents of a framebuffer.

mhagain
11-27-2015, 12:49 PM
As mentioned, glReadPixels will do it.

However, it may help us to help you better if you talked a little about why you want to do this. While you can just issue a glReadPixels call and get the pixel data, it's not always the ideal solution for all problems, and depending on the problem you're trying to solve, there are probably better ways.

wcx730916119
11-28-2015, 01:21 AM
As mentioned, glReadPixels will do it.

However, it may help us to help you better if you talked a little about why you want to do this. While you can just issue a glReadPixels call and get the pixel data, it's not always the ideal solution for all problems, and depending on the problem you're trying to solve, there are probably better ways.

Thanks for your help.
I am trying to generate image data to build an object recognition system using machine learning algorithms, so I need to know what every pixel means.
It might be not difficult to get the RGB values, but I want to know the meaning of pixels.
For example, which pixel can be labeled as cars, and which pixel can be labeled as roads.

Alfonse Reinheart
11-28-2015, 06:09 AM
Thanks for your help.
I am trying to generate image data to build an object recognition system using machine learning algorithms, so I need to know what every pixel means.
It might be not difficult to get the RGB values, but I want to know the meaning of pixels.
For example, which pixel can be labeled as cars, and which pixel can be labeled as roads.

OpenGL is a rendering system, not an image recognition system. It's job is to draw triangles, not to understand the "meaning" of those triangles.

If you know what a particular triangle "means", you can associate that data with that triangle and write it to a buffer in your framebuffer. But OpenGL itself won't have any particular "meaning" attached to anything it renders.

wcx730916119
11-28-2015, 07:54 AM
OpenGL is a rendering system, not an image recognition system. It's job is to draw triangles, not to understand the "meaning" of those triangles.

If you know what a particular triangle "means", you can associate that data with that triangle and write it to a buffer in your framebuffer. But OpenGL itself won't have any particular "meaning" attached to anything it renders.


For example, when OpenGL is rendering a blue sky with white clouds, how does it know that which triangle should be white? Is there anything telling OpenGL that some triangles should be covered by white but not the background color blue?
If I really need to know the meaning of those rendered triangles, what should I learn?

Thanks.

Alfonse Reinheart
11-28-2015, 09:44 AM
For example, when OpenGL is rendering a blue sky with white clouds, how does it know that which triangle should be white? Is there anything telling OpenGL that some triangles should be covered by white but not the background color blue?

Yes: you.

You tell OpenGL what to render. You tell OpenGL which triangles are white. You tell OpenGL what color a triangle is or what texture gets applied to it.


If I really need to know the meaning of those rendered triangles, what should I learn?

It's not clear what you mean by that. If you're rendering something, then by definition, you must know what you're drawing. Just like if you're making a sketch with a pencil, you have to know what you're sketching.

It makes no more sense to ask OpenGL what the meaning of something is than to ask your pencil what the meaning of a sketch is.