PDA

View Full Version : oversampling and glPixelZoom, etc

sillst
10-28-2001, 03:43 PM
Hi All,

I have the need to "oversample" images in OpenGL, and am not overly sure about how to do this.

Imagine a 9*9 pixel image. Also imagine that you need a 3*3 image from this. Everything would seem simple enough. Obviously, the oversampling rate is 3, so we split the 9*9 image into seperate 3*3 sections, and average the (colour) sum of each section to produce the pixel values for the 3*3 result. Computationally not that difficult, but where does glPixelZoom fit into the picture?! From my understanding, glPixelZoom doesn't perform this type of "oversampling", rather it "downsamples" because it looses colour information, i.e. does not average colour over a pixel section.

In the aforementioned case, to create the 3*3 image, glPixelZoom would only use 9 pixels from the original 9*9 image. This is because glPixelZoom only uses those pixels of the original 9*9 image whose centres overlap the centres of the new 3*3 image. (Obviously I am describing this with a visualisation of the 9*9 image overlayed with the resulting 3*3 image)

This is my understanding from the "Red" book and the appropriate man page, but I thought I had better ask if I am correct or not. So does this operation of glPixelZoom sound correct?!

So now what about when the 3*3 image is "floating" inside the 9*9 image, i.e. the pixel boundaries do not line up. What if the new image size is not only "floating" in the original, but is not an integer value?! In this case, values for the oversampled image may very well be calculated from many different fractional pixel values and so forth.

It seems like the only way to oversample in this case is to perform pixel manipulation and computation in something else like C, then redraw the results to another window.

Apart from the correctness of my glPixelZoom understanding, does anyone have experience with oversampling like I have commented on, or any suggestions on OpenGL functions which may prove extremely useful in this case?!

Many thanks.

Tim Sills