View Full Version : 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.
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
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.
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.
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.