Volume Rendering - Transfer Function

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,noOfColumns, noOfRows,noOfSlices,0,GL_LUMINANCE,GL_SHORT ,data);

please help…

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.

My data is in 16bit signed Integers…and i already tried GL_UNSIGNED_SHORT, but no significant differences…!!

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

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?

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)

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.

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…:slight_smile:

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]

ya that i know but that would be too large … don’t you think so…??

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.

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…???

Atleast I am not aware of any other alternate, if u find any do let me know.

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…:slight_smile:

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.

hmm…kk can u please give me links to any good tutorials/articles on these methods…!!!

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
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>