资源简介
用VTK在VC2005环境下做的医学图像三维重建,程序适合于初学者。
代码片段和文件信息
#include “vtkDICOMImageReader.h“
#include “vtkRenderer.h“
#include “vtkRenderWindow.h“
#include “vtkRenderWindowInteractor.h“
//#include “vtkVolume16Reader.h“
#include “vtkPolyDataMapper.h“
#include “vtkActor.h“
#include “vtkProperty.h“
#include “vtkOutlineFilter.h“
#include “vtkCamera.h“
#include “vtkPolyDataNormals.h“
#include “vtkStripper.h“
#include “vtkMarchingCubes.h“
int main(int argc char **argv)
{
if (argc < 2)
{
cout<<“用法: “< return 1;
}
//======================读取数据============================
vtkDICOMImageReader *v16 = vtkDICOMImageReader::New();
v16->SetDirectoryName(“d:/headsq/“);
v16->SetFilePrefix(argv[1]);
v16->SetDataSpacing(1.01.01.0);
v16->Update();
//=====================重建皮肤=============================
vtkMarchingCubes *skinExtractor = vtkMarchingCubes::New();
skinExtractor->SetInputConnection(v16->GetOutputPort());
skinExtractor->SetValue(0500);
vtkPolyDataNormals *skinNormals = vtkPolyDataNormals::New();
skinNormals->SetInputConnection(skinExtractor->GetOutputPort());
skinNormals->SetFeatureAngle(60.0);
vtkStripper *skinStripper = vtkStripper::New();
skinStripper->SetInputConnection(skinNormals->GetOutputPort());
vtkPolyDataMapper *skinMapper = vtkPolyDataMapper::New();
skinMapper->SetInputConnection(skinNormals->GetOutputPort());
skinMapper->ScalarVisibilityOff();
vtkActor *skin = vtkActor::New();
skin->SetMapper(skinMapper);
skin->GetProperty()->SetDiffuseColor(1 .49 .25);
skin->GetProperty()->SetSpecular( .3);
skin->GetProperty()->SetSpecularPower(20);
skin->GetProperty()->SetOpacity(1.0);
//=======================重建骨骼================================
vtkMarchingCubes *boneExtraractor = vtkMarchingCubes::New();
boneExtraractor->SetInputConnection(v16->GetOutputPort());
boneExtraractor->SetValue(01150);
vtkPolyDataNormals *boneNormals = vtkPolyDataNormals::New();
boneNormals->SetInputConnection(boneExtraractor->GetOutputPort());
boneNormals->SetFeatureAngle(60.0);
vtkStripper *boneStripper = vtkStripper::New();
boneStripper->SetInputConnecti
评论
共有 条评论