tags:

views:

32

answers:

0

Hi, I have 16bit grayscale data on which I would like to make such operations: For every pixel: 1) Compute sample 's' downsampling 16bit->8bit using LUT 2) Store sample in RGB (24bit - 8bit per sample) texture R=s,G=s,B=s

At the end I would like to have data that I could use in a windows DIB directly ( unsigned short 8bit per sample RGB ).

I'm using OpenGL and GLSL. As I'm quite new to OpenGL I'm totally lost. Suppose my hardware supports all necessary extensions. I have folowing idea:

1) Create RGB texture ( don't know if formats are ok ):

    glTexImage2D(GL_TEXTURE_RECTANGLE_ARB,0,GL_RGB8UI_EXT,textW,
                 textH,0,GL_RGB,GL_UNSIGNED_BYTE,0);

and attach it to the framebuffer.

2) Prepare GL_LUMINANCE16UI_EXT texture 'G' and put my data there. 3) Prepare 1D texture 'L' with precomputed LUT. 4) In pixelshader find x = L[ uniform sampler over G ] and set l_FragColor.x = x; l_FragColor.y = x; l_FragColor.z = x;

Is the idea ok? How should I create those textures and show should actually the pixel shader code look like (especially I have a little understanding of samplers) ?

Thanks, Bartek