On Mon, Jun 2, 2008 at 2:31 AM, Brendan Simons <brendansimons@yahoo.ca> wrote:
Hi all,

Sorry for the basic level of this question.  I'm absolutely new to GL
programming.  I'm trying to implement a very simple demosaicing
algorithm on the graphics card (in order to render data from a really
high-res bayer-filtered ccd sensor to the screen in real time).  I
need to be able to do the following:

1) given a "raw" image, copy the data (a matrix of unsigned bytes) to
video memory three times.

2) multiply each copy element-wise by a precomputed "mask" of 1s and
0s, so that the first copy records only the red values (all others
become 0), the second green, and the last blue.

3) Interpolate the missing colour info.  This step is different for
green, and for red/blue, but it goes something like this:   Copy a
crop of the green matrix exactly one row and one column narrower on
all sides.  Now add (again element-wise) to that copy another crop of
the green matrix, but this time shifted up one row.  And again shifted
down one row.  And again shifted left on column.  And one more shifted
right one column.  Divide the total (element-wise) by 4.

4) Copy the interpolated red, green and blue matrices to an opengl
texture.  Map the texture to a 2d square, and render the square to the
screen (resizing / rotating / flipping as desired).

I can figure out steps 1 and 4.  Ideally steps 2 and 3 would be done
in video memory, using opengl functions, but I can't find anything
that would do element-wise multiplication, addition or cropping of
matrices in the opengl stack.   Can anyone point me in the right
direction?

Thanks,
 Brendan
--
Brendan Simons


If your going to be doing manipulations like that on the GPU I think you will have to use shaders for that kind of customized computation.
Other than that you will have to do it on the CPU with arrays before sending it to GPU...which is slower.

To send it three times you will need to make 3 different textures or send it with glDrawPixels. You could also use FBOs to hold it in graphics memory instead if you want.

For step 2 the Redbook will be able to help, there are colorMasks and bitfields for excluding texture information which may be of help.




 

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
PyOpenGL Homepage
http://pyopengl.sourceforge.net
_______________________________________________
PyOpenGL-Users mailing list
PyOpenGL-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyopengl-users