Image Processing on textures

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 ?

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?


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.

then get the texture lod you want, ie with glReadPixels.
will work only for n=2^k

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?

It’s just an 8 bit terrain heightmap

Does your source heightmap change at all, over time?

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.

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.