资源描述:
《VTK中光线投射法实现体绘制》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、VTK中光线投射法实现体绘制【转】VTK中光线投射法实现体绘制1、体绘制函数VTK为使用者提供了三种用于光线投射法的函数分别是:等值面绘制函数(vtkVolumeRayCastIsosurfaceFunction);最大密度投影函数(vtkVolumeRayCastMIPFunction);合成体绘制函数(vtkVolumeRayCastCompositeFunction)其中最常用的是合成体绘制函数,最大密度投影函数在显示血管影像方面有比较好的作用。但是如图所看到的,MIP函数没有空间立体感,也就是不能提供深度的信息。2、不透明度映射函数不透明度映射函数是设置光线方向上的灰度值
2、及其不透明度映射。vtkPiecewiseFunction*opacityTransferFunction=vtkPiecewiseFunction::New();opacityTransferFunction->AddPoint(10,0.0);//灰度值及不透明度值opacityTransferFunction->AddPoint(50,0.1);opacityTransferFunction->AddPoint(200,0.1);opacityTransferFunction->AddPoint(2900,0.1);opacityTransferFunction->AddP
3、oint(2950,0.8);opacityTransferFunction->AddPoint(3050,1);//不透明度值为1则为完全不透明opacityTransferFunction->ClampingOff();3、颜色映射函数颜色映射函数是设置灰度值与RGB颜色的映射。vtkColorTransferFunction*colorTransferFunction=vtkColorTransferFunction::New();colorTransferFunction->AddRGBPoint(0.0,0.91,0.65,0.66);//灰度值及RGB颜色值color
4、TransferFunction->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);colorTransferFunc
5、tion->AddRGBPoint(3050,.9,0.0,0.0);colorTransferFunction->ClampingOff();4、梯度变换函数梯度变换函数设置灰度值变换的大小与不透明度之间的映射。vtkPiecewiseFunction*gradient=vtkPiecewiseFunction::New();gradient->AddPoint(50,.2);//灰度值变化梯度与不透明度的关系gradient->AddPoint(1500,.7);gradient->AddPoint(2000,.1);5、体数据属性设置vtkVolumeProperty*vo
6、lumeProperty=vtkVolumeProperty::New();volumeProperty->SetColor(colorTransferFunction);//载入颜色映射函数volumeProperty->SetScalarOpacity(opacityTransferFunction);//载入不透明度映射volumeProperty->SetGradientOpacity(gradient);//载入梯度映射volumeProperty->ShadeOn();volumeProperty->SetInterpolationTypeToLinear();//采
7、用线性插值6、光线投射函数设置及体绘制映射本程序采用合成体绘制函数:vtkVolumeRayCastCompositeFunction*compositeFunction=vtkVolumeRayCastCompositeFunction::New();vtkVolumeRayCastMapper*volumeMapper=vtkVolumeRayCastMapper::New();volumeMapper->SetVolumeRayCastFunction(compositeF