selecting a pixel from an image and extracting info

how can i select a pixel from an image in openGL, thru mouse clik and then extract information abt the pixel, like its brightness,color etc…

Use glReadPixels to read the pixel value from a given position.

so,when we use glReadpixels…how do we retrieve the info when we need it later ?? willya pls clarify ?? thanx

Not sure I get what you mean. You want to get the pixel value and save it for later use?

You can use glReadPixels to return the RGBA values from the colour buffer. How you infer brightness, etc is up to you. If I’m correct about the documentation each colour component is shifted and packed with the other values so that they fit in one value. Value could be 16 bit, 32 bit etc. I think you have to specify it.

well,once i get a pixel’s color information, i need to find all its neighbouring pixels with a similar color value (ie) more or less of the same color.

so,how can i do this…can anyone suggest me a way pls…

this has to go like a chain reaction,in the sense that all neighbouring pixels of similar color values are to be found one level after another.

You want a grass fire algorithm, I am assuming this is for some kind of segmentation? Just recursively checks its 8 connected neighbours or whatever filter you are using…

sorry, Im not exactly sure what a grass fire algorithm does,but then my problem requires me to check for similarity in color between the pixel chosen and its eight immediate neighbour pixels.once few of the eight pixels are found similar,the program should proceed to checking the eight neighbours of each of these similar pixels.It goes on recursively checking the whole image.