Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo
Close
From: Brendan Simons <brendansimons@ya...>  20080602 00:33:14

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 highres bayerfiltered 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 elementwise 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 elementwise) 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 (elementwise) 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 elementwise multiplication, addition or cropping of matrices in the opengl stack. Can anyone point me in the right direction? Thanks, Brendan  Brendan Simons 
From: Jason Ward <nyad55@gm...>  20080602 04:48:08
Attachments:
Message as HTML

On Mon, Jun 2, 2008 at 2:31 AM, Brendan Simons <brendansimons@...> 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 > highres bayerfiltered 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 elementwise 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 elementwise) 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 (elementwise) 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 elementwise 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 > _______________________________________________ > PyOpenGLUsers mailing list > PyOpenGLUsers@... > https://lists.sourceforge.net/lists/listinfo/pyopenglusers 
From: Greg Ewing <greg.ewing@ca...>  20080603 00:19:14

Jason Ward wrote: > 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. Also be aware that what OpenGL calls a "matrix" has nothing to do with what you're talking about here. OpenGL matrices are 4x4 matrices used for coordinate transformations only.  Greg 