基于vtkVolumeRayCastMIPFunction实现体数据的MIP显示

本文由Markdown语法编辑器编辑完成。

基本介绍:

vtkVolumeRayCastMIPFunction:
A maximum intensity projection ray caster for volumes. vtkVolumeRayCastMIPFunction is a volume ray cast function that computes the maximum value encountered along the ray. This is either the maximum scalar value, or the maximum opacity, as defined by the MaximizeMethod. The color and opacity returned by this function is based on the color, scalar opacity, and gradient opacity transfer functions defined in the vtkVolumeProperty of the vtkVolume.

关于基于这个类实现三维体数据的MIP的基本框架代码如下:

vtkSmartPointer<vtkImageData> pImage =   vtkSmartPointer<vtkImageData>::New();

//vtkImageShiftScale是负责转换数据类型的.
vtkSmartPointer<vtkImageShiftScale> pImageScale =vtkSmartPointer<vtkImageShiftScale>::New();

//pImage应该是要显示MIP的原始体数据,可以是从文件里面读取出来,也可以是通过前面的管道传递过来的图像数据.
pImageScale->SetInputData(pImage);
//MRI图像的灰度值始终大于0,因此可以转换成UnsignedShort.
pImageScale->SetOutputScalarTypeToUnsignedShort();
//CT图像的灰度值有负数,因此需要转换成Double或float.
//pImageScale->SetOutputScalarTypeToDouble();

vtkSmartPointer<vtkVolumeRayCastMIPFunction> mipFunction= vtkSmartPointer<vtkVolumeRayCastMIPFunction>::New();
//最大密度投影.
mipFunction->SetMaximizeMethodToScalarValue();

//Mapper是负责把体数据按照设定的方式,进行数据映射的。
vtkSmartPointer<vtkVolumeRayCastMapper> rayCastMapper = vtkSmartPointer<vtkVolumeRayCastMapper>::New();
vtkSmartPointer<vtkVolumeMapper> pVolumeMapper =
vtkSmartPointer<vtkVolumeMapper>::New();
rayCastMapper->SetVolumeRayCastFunction(mipFunction);
pVolumeMapper = rayCastMapper;
pVolumeMapper->SetInputConnection(pImageScale->GetOutputPort());

vtkSmartPointer<vtkVolumeProperty> pVolumeProperty = vtkSmartPointer<vtkVolumeProperty>::New();
pVolumeProperty->SetInterpolationTypeToLinear();
pVolumeProperty->ShadeOff();
pVolumeProperty->SetDiffuse(1.0);

//vtkVolume和vtkActor类似,都是最后要显示在vtkRenderer中的图像.这里设置vtkVolume的一些属性,mapper和property。
vtkSmartPointer<vtkVolume> m_pVolume = vtkSmartPointer<vtkVolume>::New();
m_pVolume->SetMapper(pVolumeMapper);
m_pVolume->SetProperty(pVolumeProperty);
m_pVolume->PickableOn();

vtkSmartPointer<vtkRenderer> m_pRenderer =
vtkSmartPointer<vtkRenderer>::New();
m_pRenderer ->AddActor(m_pVolume);
m_pRenderer ->GetActiveCamera()->ParallelProjectionOn();

vtkSmartPointer<vtkRenderWindow> m_pRenderWindow =
vtkSmartPointer<vtkRenderWindow>::New();
m_pRenderWindow->AddRender(m_pRenderer);
m_pRenderWindow->Render();

附图是应用VTK对一组脑部血管的MRI图像进行MIP成像后的显示结果:
基于vtkVolumeRayCastMIPFunction实现体数据的MIP显示_第1张图片

基于vtkVolumeRayCastMIPFunction实现体数据的MIP显示_第2张图片

可以看到,白色的管状物就是大脑当中分布的错综复杂的血管。通过MIP可以观察到一个人大脑的血管形态,以及是否发生病变,对于及早防治有很重要的作用。

参考链接:

  1. vtkVolumeRayCastMIPFunction的例子:
    http://www.vtk.org/gitweb?p=VTK.git;a=blob;f=Rendering/Volume/Testing/Cxx/volProt.cxx

你可能感兴趣的:(VTK,医学影像处理)