Volume Rendering by ray projection in VTK
1. Volume Rendering Function
VTK provides users with three functions for ray projection:
Isosurface rendering function (vtkvolumeraycastisosurfacefunction );
Maximum density projection function (vtkvolumeraycastmipfunction );
Synthesis and volume rendering function (vtkvolumeraycastcompositefunction)
The most common function is the synthesis and volume rendering function. The maximum density projection function plays a good role in displaying vascular images. However, as we can see, the MIP function does not have a space stereoscopy, that is, it cannot provide depth information.
2. Opacity ing Function
The opacity ing function is used to set the gray value and its opacity ing in the light direction.
Vtkpiecewisefunction * opacitytransferfunction = vtkpiecewisefunction: New ();
Opacitytransferfunction-> addpoint (10, 0.0); // grayscale value and opacity value
Opacitytransferfunction-> addpoint (50, 0.1 );
Opacitytransferfunction-> addpoint (200, 0.1 );
Opacitytransferfunction-> addpoint (2900, 0.1 );
Opacitytransferfunction-> addpoint (2950, 0.8 );
Opacitytransferfunction-> addpoint (3050,1); // If the opacity value is 1, it is completely opaque.
Opacitytransferfunction-> clampingoff ();
3. Color ing Function
The color ing function is used to set the ing between the gray value and the RGB color.
Vtkcolortransferfunction * colortransferfunction = vtkcolortransferfunction: New ();
Colortransferfunction-> addrgbpoint (0.0, 0.91, 0.65, 0.66); // grayscale value and RGB color value
Colortransferfunction-> addrgbpoint (30.0, 0.91, 0.65, 0.66 );
Colortransferfunction-> addrgbpoint (128.0, 0.91, 0.65, 0.66 );
Colortransferfunction-> addrgbpoint (1200.0, 0.43, 0.43, 0.43 );
Colortransferfunction-> addrgbpoint (1800.0, 0.43, 0.43, 0.43 );
Colortransferfunction-> addrgbpoint (2950,. 9, 0.0, 0.0 );
Colortransferfunction-> addrgbpoint (3050,. 9, 0.0, 0.0 );
Colortransferfunction-> clampingoff ();
4. Gradient transformation Functions
The gradient transform function sets the ing between the gray value transformation size and opacity.
Vtkpiecewisefunction * gradient = vtkpiecewisefunction: New ();
Gradient-> addpoint (50,. 2); // relationship between gradient and opacity when the gray value changes
Gradient-> addpoint (1500,. 7 );
Gradient-> addpoint (2000,. 1 );
5. Set body data attributes
Vtkvolumeproperty * volumeproperty = vtkvolumeproperty: New ();
Volumeproperty-> setcolor (colortransferfunction); // The color ing function is loaded.
Volumeproperty-> setscalaropacity (opacitytransferfunction); // load opacity ing
Volumeproperty-> setgradientopacity (gradient); // load gradient ing
Volumeproperty-> shadeon ();
Volumeproperty-> setinterpolationtypetolinear (); // use linear interpolation
6. Ray Projection Function setting and volume rendering ing
This program uses the synthetic volume rendering function:
Vtkvolumeraycastcompositefunction * compositefunction =
Vtkvolumeraycastcompositefunction: New ();
Vtkvolumeraycaw.apper * volumemapper = vtkvolumeraycaw.apper: New ();
Volumemapper-> setvolumeraycastfunction (compositefunction); // volume loading method
Volumemapper-> setinput (append-> getoutput (); // load image data
Volumemapper-> setsampledistance (. 5 );
Vtkvolume * volume = vtkvolume: New ();
Volume-> setmapper (volumemapper); // sets the ing.
Volume-> setproperty (volumeproperty); // you can specify a property.