GLPixelMapping in hardware vs. software

I’m trying to use the GPU to do contrast enhancement or histogram equalization and am seeing it work correctly for the displayed images but my CPU usage goes way up when glPixelTransferf() is enabled. Therefore the remapping of pixel intensities must be happening in software not hardware. How can I ensure my graphics hardware will do the remapping?

The following five lines are the calls used to do Histogram equalization with OpenGL. The problem I’m having is that the last of these lines is causing the CPU usage to go up so it’s not using the GPU.
glPixelMapfv(GL_PIXEL_MAP_R_TO_R, 256, pixelMapGreen);
glPixelMapfv(GL_PIXEL_MAP_B_TO_B, 256, pixelMapGreen);
glPixelMapfv(GL_PIXEL_MAP_G_TO_G, 256, pixelMapGreen);
glPixelMapfv(GL_PIXEL_MAP_A_TO_A, 1, &constantAlpha_);
glPixelTransferf(GL_MAP_COLOR, GL_TRUE);

I have to tell you that the imaging functions seem to be only supported in software for most consumer video cards.

So the alternative is to go with a GLSL fragement shader, and fetch the data you need from a texture.
You can easily grab the green channel and put it to the red and blue, scale it etc.

Or give more details about your needs.

Thanks for the reply.
We are currently using texture shaders for other things like sharpening filters and bilinear interpolation.
Is there a way to tell what hardware supports pixel re-mapping?
We can get new video cards.

If you mean glPixelTransferf(GL_MAP_COLOR, GL_TRUE); the answer is probably none. At least none you would care about.

If you mean which hardware supports fragment shaders, the answer is all which export any of the ARB_/EXT_/NV_fragment_program extensions, ARB_fragment_shader resp. OpenGL 2.0 (implies GL Shading Language).

A list of exported extensions from various board and driver combinations can be found on This is it

So glPixelMap() is not supported in hardware by any vendors? What about using glColorTable() for remapping pixel values?

I’m trying to stay away from using shaders as we have reserved them for more complex filtering such as demosaicing our raw Bayer pattern image.

There must be a simple way to have this done by the GPU.

I just want to rephrase my intitial question to ask , “Does anyone know of a way to ensure that pixel intensity remapping happens in hardware using either glPixelTransfer*() or alternatively glColorTable()?”

Thanks Relic for the last response which pointed me to a website which shows what hardware supports GL_ARB_imaging extenstions. Is it correct to assume that using such a graphics card with glColorTable will ensure pixel mapping happens in hardware? I see nothing that indicates glPixelMap can ever be made run on a GPU. Is there anyone who knows different?

I don’t know of a mainstream implementation which supports pixelmap in hardware. I think I’ve seen an expensive NEC board in 1997 which did this, this falls under the “none you would care about” category I mentioned.

If you mean glColorTable in combination with paletted textures? Support for paletted textures has stopped on NVIDIA boards (look up the comment in the spec: ) now that the fragmet pipeline is programmable and fast enough.

Paletted textures were nice, no question, and emulating the exact behaviour is comparably costly, but you can do the same with dependent texture fetches and there are really more interesting things to do with fragment programs.

The state of the art solution to your color modification requirements is to implement them in a fragment shader which works on the original texture data. If you need that converted as a texture and the conversion is costly, render it to a second texture and use that.

There is really no reason to avoid fragment shaders for such things when you use them for more advanced stuff anyway. Just unify your approach and use them for the simple stuff as well.

Well it sounds like there is no simple solution to getting pixel intensity remapping. I say that becasue I am not very fluent in shader language. If you know of any example code that I might try which does two different types of shaders sequentially it would help kick start me on this. I was planning to use PixelMap and Convolution2D for the remaining image processing functions to be implemented but it seems as thought neither will run on the GPU so I have ot use shaders for sharpening and equalization.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.