資源描述:
《VTK中光線投射法實現(xiàn)體繪制》由會員上傳分享,免費在線閱讀,更多相關內容在應用文檔-天天文庫。
1、VTK中光線投射法實現(xiàn)體繪制【轉】VTK中光線投射法實現(xiàn)體繪制1、體繪制函數(shù)VTK為使用者提供了三種用于光線投射法的函數(shù)分別是:等值面繪制函數(shù)(vtkVolumeRayCastIsosurfaceFunction);最大密度投影函數(shù)(vtkVolumeRayCastMIPFunction);合成體繪制函數(shù)(vtkVolumeRayCastCompositeFunction)其中最常用的是合成體繪制函數(shù),最大密度投影函數(shù)在顯示血管影像方面有比較好的作用。但是如圖所看到的,MIP函數(shù)沒有空間立體感,也就是不能提供深度的信息。2、不透明度映射函數(shù)不透明度映射函數(shù)是設置光線方向上的灰度值
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、顏色映射函數(shù)顏色映射函數(shù)是設置灰度值與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、梯度變換函數(shù)梯度變換函數(shù)設置灰度值變換的大小與不透明度之間的映射。vtkPiecewiseFunction*gradient=vtkPiecewiseFunction::New();gradient->AddPoint(50,.2);//灰度值變化梯度與不透明度的關系gradient->AddPoint(1500,.7);gradient->AddPoint(2000,.1);5、體數(shù)據(jù)屬性設置vtkVolumeProperty*vo
6、lumeProperty=vtkVolumeProperty::New();volumeProperty->SetColor(colorTransferFunction);//載入顏色映射函數(shù)volumeProperty->SetScalarOpacity(opacityTransferFunction);//載入不透明度映射volumeProperty->SetGradientOpacity(gradient);//載入梯度映射volumeProperty->ShadeOn();volumeProperty->SetInterpolationTypeToLinear();//采
7、用線性插值6、光線投射函數(shù)設置及體繪制映射本程序采用合成體繪制函數(shù):vtkVolumeRayCastCompositeFunction*compositeFunction=vtkVolumeRayCastCompositeFunction::New();vtkVolumeRayCastMapper*volumeMapper=vtkVolumeRayCastMapper::New();volumeMapper->SetVolumeRayCastFunction(compositeF