Volume_Rendering_Using_GLSL icon indicating copy to clipboard operation
Volume_Rendering_Using_GLSL copied to clipboard

Method to set transfer function

Open xiasun opened this issue 9 years ago • 5 comments

Hi,

I want to know how to set/generate a transfer function myself, could you give me some suggenstion?

Many thanks

xiasun avatar Jul 24 '16 08:07 xiasun

I also want to know how can I set/generate my own transfer function.

dugarsumit avatar Aug 02 '17 21:08 dugarsumit

I use Voreen to get a transfer function that looks good, export it and then create a table manually that matches intensity value with opacity and color. This is how I do.

xiasun avatar Aug 03 '17 04:08 xiasun

Sorry if these questions seems silly..I am doing volume rendering for the first time. From my understanding a transfer function can be considered as a mapping between intensities values of the voxels to image properties like color and opacity. Does Voreen allow you to manually set this mapping? If yes, then why can't you simply export from Voreen? What do you mean that you need to create a table manually after exporting to match intensity value with opacity and color?

Are you aware of any algorithm that generates transfer function automatically? I tried googling it but couldn't find much.

dugarsumit avatar Aug 03 '17 07:08 dugarsumit

What I did is creating a TF with good rendering results on Voreen by GUI, then export this TF as xml file and recreate it in this code, for example, the xml file shows that intensity A has opacity a and intensity B has opacity b, and I do a linear interpolation between A and B in this rendering code.

Automatic TFs to my understanding are based on global features of the volume data like histograms. I haven't done anything on this topic yet. By googling I got some semi-automatic TFs related papers, I think you may get some ideas form them.

Could you let me know if you find any useful papers on automatic TFs? Many thanks~

xiasun avatar Aug 04 '17 03:08 xiasun

The transfer function maps the intensity of your volume to a RGBA value (red,green,blue,alpha), where Alpha is you opacity. You may want adapt features from my MRIcroGL. This uses 256 RGBA values. The most basic lookup would be grayscale, where one interpolates from transparent black (RGBA=0,0,0,0) to opaque white (RGBA=255,255,255,255). Next you have to map these 256 colors to the input intensities in your volume. For CT scans, intensities are calibrated (-1000=air, 0=water, 1000=bone), but for most modalities you simply rank order the intensities of your input volume and set brightnesses at or below the 2nd percentile to the 1st color in your palette (e.g. black) and those at or above the 98th percentile to the 256th color in the palette, with intermediate colors interpolated. This is a good heuristic to deal with outliers.

With MRIcroGL, you can choose View/ColorEditor to interactively adjust your transfer function. Clicking on a node lets you change the RGB value and moving the node up and down adjusts the Alpha. (see screenshot)

If you want, you can adapt this project to read the CLUT (color lookup tables) text files that MRIcroGL uses for the transfer functions. For example, the 'bone' colorscheme below goes from black to white via an intermediate blue.

[INT]
numnodes=3
[BYT]
nodeintensity0=0
nodeintensity1=153
nodeintensity2=255
[RGBA255]
nodergba0=0|0|0|0
nodergba1=103|126|165|76
nodergba2=255|255|255|128

bone

neurolabusc avatar Aug 04 '17 13:08 neurolabusc