vtkVolumeRayCastCompositeFunction

vtkVolumeRayCastCompositeFunction是一个和光线有关的函数,可以在vtkVolumeRayCastMapper类中使用。它根据vtkVolumeProperty中的属性来对光线进行混合操作。(vtkVolumeRayCastCompositeFunction is a ray function that can be used within a vtkVolumeRayCastMapper. This function performs compositing along the ray according to the properties stored in the vtkVolumeProperty for the volume.)‘

    该方式通过Alpha合成技术生成每个像素的颜色值。对于每条管线在穿过体数据时,先根据的设置的采样进行采样,通过插值技术来计算每个采样点的像素值,然后根据VTKVolunmeProperty 中设置的颜色传输函数和不透明度传输函数来计算采样点的颜色和不透明度,最后对所有采样点采用Alpha合成方法计算最终的颜色。

    另外,该方式还可以设置插值优先还是分类优先。插值优先是指对投射光线进行采样,计算采样点的颜色时,先通过插值方式计算该采样点的标量值(灰度值),然后根据颜色传输函数和不透明函数传输函数计算该采样点的颜色值和不透明度。分类优先则是指在计算采样点时现根据颜色传输函数和不透明度传输函数计算包含该采样点的立方体的8个顶点颜色值和不透明度,然后通过插值方法获取当前采样点的颜色值和不透明度。设置插值优先和分类优先的函数如下。
vtkVolumeRayCastCompositeFunction
 
  很多时候体绘制的实现只要调用对应的函数即可,为了使得每个区域的颜色不一致,所以对vtkVolumeRayCastCompositeFunction的源码做了修改。
(1)void CastRay( vtkVolumeRayCastDynamicInfo *dynamicInfo ,vtkVolumeRayCastStaticInfo *staticInfo )
 

vtkVolumeRayCastCompositeFunction

根据插值的方式以及传入参数的类型分别进入不同的函数。
插值方式有两种,interpolatefirst 和 classifyfirst。
(2)工作设置的插值方式是classifyfirst,实现的是dicom体绘制。进入的函数是vtkCastRay_TrilinVertices_Shaded()。
    函数中的部分参数;
     float  A,B,C,D,E,F,G,H;//A为一个体素,其他的七个是A的八邻域体素表示

     float           *SOTF;//the scalar opacity transfer function which maps scalar input values to opacities
     float           *CTF; //the color transfer function which maps scalar input values to RGB values,CT值与RGB的对应关系
     float           *GTF;
     float           *GOTF;// the gradient opacity transfer function for this volume (which maps gradient magnitudes to  
                                      opacities)

     float           red_shaded_value, green_shaded_value, blue_shaded_value;//光线跟踪最后得到的rgb颜色值

在这个条件下修改对应代码
原先的vtk代码如下:vtkVolumeRayCastCompositeFunction

vtkVolumeRayCastCompositeFunction
A为通量的值

vtkVolumeRayCastCompositeFunction
修改为上述的代码,就可以对绘制的颜色做修改。

参考链接:
       体绘制    https://blog.****.net/weixin_38500110/article/details/78631053?locationNum=5&fps=1
      体绘制算法   https://blog.****.net/menjiawan/article/details/46470797
     体绘制讨论_颜色传输函数       https://blog.****.net/shenziheng1/article/details/54915682
     读取DICOM文件               https://blog.****.net/u012176176/article/details/51259216
    体绘制_光线投影+最大密度投影+等值面法       https://blog.****.net/shenziheng1/article/details/54893265?locationNum=7&fps=1
           三维立体显示         https://www.cnblogs.com/unsigned/archive/2010/03/29/1699821.html
     基于VTK的体绘制系统实现     https://blog.****.net/xizmi/article/details/17710797