PDA

View Full Version : apply color lut for grayscale images



hanoglu
06-15-2010, 03:50 AM
i create a texture with internal format gl_limunance12.
i want to apply lut for this grayscale medical image image to make it colorized.

if ve tried glPixelMapfv. it works for rgb images but grayscale images.

is there any way to do it with opengl?

GL Starter
06-15-2010, 05:22 AM
If u can use a shader program to perform this lookup.

uniform sampler2D InputTexture;
uniform sampler2D ColorMap;
PS_OUT main(PS_IN In)
{
float4 fTexData = tex2D( InputTexture, In.texture0 );
PS_OUT out;
out.color0 = text1D( ColorMap, fTexData.a );
return out;
}

hanoglu
06-15-2010, 09:08 AM
i know few about glsl.

i ve compiled it and got some errors
0(3) : error C0000: syntax error, unexpected '(' at token "("
0(3) : error C0501: type name expected at token "("
0(3) : warning C7022: unrecognized profile specifier "main"
0(3) : warning C7022: unrecognized profile specifier "PS_OUT"
0(5) : error C1115: unable to find compatible overloaded function "tex2D(sampler2D, error)"
0(6) : error C0000: syntax error, unexpected '';'' at token ";"
0(6) : error C0501: type name expected at token ";"
0(6) : warning C7022: unrecognized profile specifier "PS_OUT"
0(8) : error C0000: syntax error, unexpected reserved word "return" at token "return"
0(8) : error C0501: type name expected at token "return"
0(8) : warning C7537: OpenGL does not allow ''inout'' after a type specifier

lobbel
06-17-2010, 04:49 PM
Hi,
first if you use 8bit data use just luminance.

the shader for simple 1d transfer function for texture sliced
volume rendering is easy.



sampler3D volumeTex;
sampler1D lutTex;
void main()
{
float iso = texture3D(volumeTex, texCoord.xyz);
vec4 color = texture1D(lutTex, iso);
gl_FragColor = color;
}


regards,
lobbel

GL Starter
06-17-2010, 09:02 PM
Please refer pixel shader tutorial.

http://www.opengl.org/news/comments/tutorial_cg_pixel_shaders_in_opengl/

http://joshbeam.com/articles/cg_pixel_shaders_in_opengl/

Definition of VS_OUT and PS_OUT are
struct VS_OUTPUT
{
float4 color0 : COLOR0;
float2 texcoord0 : TEXCOORD0;
};

struct PS_OUTPUT
{
float4 color : COLOR;
};