PDA

View Full Version : Image Processing on textures



07-02-2005, 05:04 PM
I want to do simple filter operations on a loaded image (maybe a texture on a one sided quad) , I was wondering if there are methods such as getPixel() etc to get the grey level intensity or RGB of a particular region on a image ?

07-03-2005, 09:31 PM
There is no such function.

You can do the same thing on the CPU with the raw image data. If you only need to do this once, you'll probably want to do this on the cpu, at image load time. If you need to do this often at runtime, you'll probably want programs/shaders.

What kind of filter did you have in mind?

Hlz

07-05-2005, 02:34 PM
I simply want to get the average of all the pixels in a NxN mask over the whole image (So the new image will be rather pixellated version of the original) , I'll use this in a path finding algorithm where the grey level intensity represents weighting.

I was hoping openGL could supply some methods but I may have to find a image Library somewhere.

ZbuffeR
07-05-2005, 02:43 PM
glTexParameteri( GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_TRUE );
then get the texture lod you want, ie with glReadPixels.
will work only for n=2^k

07-05-2005, 04:35 PM
Good idea, ZbuffeR.


I'll use this in a path finding algorithm where the grey level intensity represents weighting.interesting. What's the source of your data?

07-05-2005, 04:49 PM
It's just an 8 bit terrain heightmap

07-05-2005, 04:55 PM
Does your source heightmap change at all, over time?

07-05-2005, 06:16 PM
No but my representative grid taken from the Heightmap (i.e through the NxN filter I'm trying to build) will change depending on how many units are nearby, if that grid is an objective , if it has been acquired by friend or enemy etc. I'm really trying to lower the original resolution of the heightmap down to about 60x60 (keeping aspect ratio) because I think the A* pathfinding algorithm works better within that range. Each Grid square within that 60x60 will be the average (using neighbourhood averaging filter) of that region on the heightmap.

07-06-2005, 11:12 AM
Cool idea.

I'm also thinking a precomputed quadtree might be an intersting alternative. Selective adaptation is easy if a parent is the average of its children (2x2 filter). But this is getting into a realm unrelated to opengl...

Good luck with this.

Hlz