PDA

View Full Version : Volume Rendering - Transfer Function



abhishek bansal
02-23-2011, 11:08 PM
Hi all,

I was working on a volume rendering application with 8 bit/pixel datasets. I am using post-classification method for transfer function implementation. Now what i want to do is to extend this application for 16 bit datasets. My problem is that how to implement transfer function for 16 bit data.

Previously i was sending 1D texture to my fragment shader right away but now for 16 bit this would be too large.

And i also had a doubt that if all textures are scaled to range [0,1] then my 8 bit transfer function should have worked but it is giving me very bad quality output. (results of 8 bit and 16 bit datasets are attached)
glTexImage in case of 16 bit dataset


glTexImage3D(GL_TEXTURE_3D,0,GL_INTENSITY16,noOfCo lumns, noOfRows,noOfSlices,0,GL_LUMINANCE,GL_SHORT ,data);


please help....

mobeen
02-23-2011, 11:22 PM
Hi,
Is your data signed or unsigned? In case of unsigned data, u should pass GL_USHORT to the second last parameter.

See if this helps.

abhishek bansal
02-23-2011, 11:29 PM
My data is in 16bit signed Integers..and i already tried GL_UNSIGNED_SHORT, but no significant differences...!!

mobeen
02-23-2011, 11:55 PM
How is your dataset sampler declared in the shader?

abhishek bansal
02-23-2011, 11:56 PM
How is your dataset sampler declared in the shader?

here is my complete fragment shader


float4 main(uniform sampler3D dataTex,
uniform sampler1D tfTex,
float3 texCoord : TEXCOORD0,
float4 color : COLOR) : COLOR
{
float v = tex3D(dataTex,texCoord); // Read 3D data texture and
color = tex1D(tfTex,v); // transfer function texture
return color;
}

dataTex is sampler for dataset
tfTex for transfer function

mobeen
02-24-2011, 12:06 AM
Your shader looks ok and since the sampler3D type is used the return float will be normalized so it should work with the 8bit tf. Is this a public dataset may be the dataset is like that? Have u tried using volview or another volume rendering pkg to see what u get?

abhishek bansal
02-24-2011, 12:36 AM
may be the dataset is like that?

well i dont think so because this is second dataset with which i m trying.With previous one (http://www.cgl.uwaterloo.ca/~iebell/CS788H-0105/cs788.html)(iebellBrain.tar.gz) i didn't even got any kind of structure but just a volume cube...that dataset i verified with Voreen(which produce so fine results that i feel like a idiot)

link for this dataset is :
http://graphics.stanford.edu/data/voldata/
(MRbrain)

mobeen
02-24-2011, 01:47 AM
I think the endianess of the file is big endian. You should thus swap your bytes when reading from the file.

See if this helps.

abhishek bansal
02-24-2011, 11:47 AM
I think the endianess of the file is big endian. You should thus swap your bytes when reading from the file.\


Awesome man...that did the trick !!! thanks a ton...

Now can u plz suggest me a proper way of implementing 16 bit Transfer Functions... that would be very kind of you..:)

mobeen
02-24-2011, 07:44 PM
Now can u plz suggest me a proper way of implementing 16 bit Transfer Functions... that would be very kind of you..:)
I think 8 bit tf would work too but if u want 16 bit then simply extend the lut to 16bit.
If previously u defined the 8bit lut 1D texture like this

GLubyte lut_data_8[256][4];
then u can generate the new lut by simply extending the range

GLubyte lut_data_16[65536][4]

abhishek bansal
02-25-2011, 02:14 AM
then u can generate the new lut by simply extending the range

GLubyte lut_data_16[65536][4]

ya that i know but that would be too large ... don't you think so...??

mobeen
02-25-2011, 02:34 AM
You have a 16bit dataset and thus u would need 2^16 entries in ur lookup table which gives u more control on the intensity differences as compared to using the 8bit lut. Ofcourse u can remap the 16bit value to an 8 bit if u want to use the 8bit lut.

abhishek bansal
02-25-2011, 02:42 AM
ya i understand your point but that would be like 262 MB for a single texture....would not that hinder performance significantly...Isn't there some another way for implementing this TF...???

mobeen
02-25-2011, 03:03 AM
Atleast I am not aware of any other alternate, if u find any do let me know.

abhishek bansal
02-25-2011, 04:05 AM
ohk...i hav heard of two dimensional TF's and preintegration technique but i do not know much about them.. anyways thanx a lot for your help...:)

mobeen
02-25-2011, 05:23 AM
ohk...i hav heard of two dimensional TF's and preintegration technique but i do not know much about them.. anyways thanx a lot for your help...:)
2D tf have intensity on the x axis (0-255 for 8bit and 0-65535 for 16bit) and the gradient magnitude on the y axis so it would need more space for 16bit tf as compared to 16bit 1D tf.
The preintegration tf needs a nxnx4 data elements. Value of n for 8 bit lut is 256 and 16bit lut i 65536.

abhishek bansal
02-25-2011, 05:26 AM
hmm..kk can u please give me links to any good tutorials/articles on these methods...!!!

mobeen
02-25-2011, 09:05 PM
You can refer to the following papers/links
2D transfer functions were invented by Gordan Kindlemann and later extended by Joe Kniss. Check his paper here (http://www.cs.utah.edu/~jmk/kniss_tvcg02-small.pdf)
Preintegrated vr was invented by Klaus Engel. Details are here
<a href="http://www.vis.uni-stuttgart.de/~engel/pre-integrated/" rel="nofollow" target="_blank">http://www.vis.uni-stuttgart.de/~engel/pre-integrated/
</a>