View Full Version : hard problem or impossible ?

05-13-2011, 04:34 AM
Hi all, i'm trying to solve an image analysis problem using a shader and just wondered if anyone here knew a way to solve it.

The problem is this : i have a binary image such that there are 'blobs' of various sizes which will be white and the background will be black in my texture and what i am trying to do is use a shader to identify the bounding box of each of the 'blobs' of white writing the bounding box of the 'blobs' into the RGBA channels of each pixel within each 'blob'.

Anyone know a quick way of doing this ? currently i am trying to render the 'blobs' texture to a 2nd texture that just has the blob outlines then using the blob outline texture i'm trying to use a shader to trace the outlines of the blobs and write the max/min x and y texture coordinates into a new texture but its proving fairly difficult to get to work ....

So is this problem solvable or should i just give up ? i was hoping the speed of a shader would out perform the current way i generate bounding boxs for the blobs (which is going through the whole data set labeling connected pixels to grow their bounding boxs)

Comments/suggestions welcome



Ilian Dinev
05-13-2011, 10:34 AM
My first idea, how to start-up is:
- start rendering to an "unsigned char" GL_R8 FBO/texture
- for every pixel, if black: outColor=0. If white, sample the surrounding 8 pixels (in a 3x3 grid), and if they're white - set a bit in outColor, So, if all surrounding texels are white, outColor=255; if they're all black: outColor=0, if only the texel to the right is white: outColor = (1<<4);

- start making mip-map levels in a custom way, and maybe in separate textures (to not need to make lower levels 4x smaller - but e.g 9x smaller). May need to have their texture-format be GL_R32UI. The output color values should let you easily identify huge blobs later.