PDA

View Full Version : reducing images



Hubert
09-30-2001, 02:43 AM
after rendering an image, is there an easy way to create another image say 1/10th the size consisting of the 1st, 11th, 21st pixels etc?
and then another with the 2nd, 12th, 22nd pixels and so on?

thanks,
hu.

Bob
09-30-2001, 11:37 PM
Two ways I know about.

#1 Use glReadPixels and extract the pixels yourself.
#2 Copy the image to a texture, use GL_NEAREST as minification filter, draw a quad and pass it the necessary texture coordinates to make it hit the pixels you want.

I can for sure say, if you don't know to 100% how the texel-hit stuff works in OpenGL, I would strongly recomend #1.

pATChes11
10-01-2001, 06:09 PM
Clarify wtf it is you're doing. And you don't want to use any glxxxxPixels functions, for they eat the hell out of your performance. If you want to take an image out of the framebuffer, then you should put the framebuffer to where you can get it more easily, like a memory DC. At least it isn't as slow as glReadPixels... :P

And why use GL_NEAREST when anisotrophic filtering looks so much better than even mipping? :P If you can't do that, use GL_LINEAR_MIPMAP_LINEAR; it will look lots better. That is, if you're going to use the god-awful-slow-to-read-from framebuffer.

If you use my memory context idea, then you'll have to figure out linear interpolation or texel hitting (the former is better looking, but more CPU intensive and much harder to code) however. I dunno, I'm just tired and I babble on pointlessly because I have nothing better to do.

Bob
10-01-2001, 10:59 PM
I didn't advice him to use GL_LINEAR because it looks good, I did it because GL_LINEAR uses only one texel. GL_LINEAR_MIPMAP_LINEAR is a weighted average of the eight surrounding texels, and it might be a bit difficult to hit a single texel only with that minification filter. With GL_LINEAR, a certain "fault" in texture coordinates is OK.

Michael Steinberg
10-02-2001, 03:56 AM
GL_NEAREST!

marcus256
10-02-2001, 04:27 AM
after rendering an image,

Are you rendering with OpenGL?

is there an easy way to create another image say 1/10th the size consisting of the 1st, 11th, 21st pixels etc?
and then another with the 2nd, 12th, 22nd pixels and so on?


What will you be using it for? Is the image rendered every frame or more seldom? One thing to consider is that when downsampling an image, you should low pass filter it before subsampling (basically what FSAA does) if each subsampled image is to be viewed separately.


/Marcus

Bob
10-02-2001, 04:54 AM
Michael, you are so correct. I was right in my first post, but wrong in my second. GL_NEAREST is what I meant instead of GL_LINEAR. Typo, or just a tired head, I don't know http://www.opengl.org/discussion_boards/ubb/biggrin.gif

doodlemunch
01-14-2006, 12:30 AM
does any1 know about an acceleratet method for making a texture smaller by 2,4,8,etc. ??

i can do it in the cpu but i think gpu could be faster?

jide
01-14-2006, 01:39 AM
Originally posted by doodlemunch:
does any1 know about an acceleratet method for making a texture smaller by 2,4,8,etc. ??

i can do it in the cpu but i think gpu could be faster?Simply use mipmaps if that's what you was meaning.