VTK皮肤与骨骼抽取

读取一系列人体头部二维切片,抽取皮肤与骨骼

console下实现如下:

#include 
VTK_MODULE_INIT(vtkRenderingOpenGL2);
VTK_MODULE_INIT(vtkInteractionStyle);
VTK_MODULE_INIT(vtkRenderingFreeType);
VTK_MODULE_INIT(vtkRenderingVolumeOpenGL2);
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
int main()
{
	vtkSmartPointerrender = vtkSmartPointer::New();
	vtkSmartPointerrenWin = vtkSmartPointer::New();
	renWin->AddRenderer(render);

	vtkSmartPointeriren = vtkSmartPointer::New();
	iren->SetRenderWindow(renWin);

	vtkSmartPointerv16 = vtkSmartPointer::New();
	v16->SetDataDimensions(64, 64);
	v16->SetDataByteOrderToLittleEndian();
	v16->SetFilePrefix("F:\\vtkshuju\\Data\\headsq\\quarter");
	v16->SetImageRange(1, 93);
	v16->SetDataSpacing(3.2, 3.2, 1.5);

	vtkSmartPointerskinExtractor = vtkSmartPointer::New();
	skinExtractor->SetInputConnection(v16->GetOutputPort());
	skinExtractor->SetValue(0, 500);

	vtkSmartPointerskinNorms = vtkSmartPointer::New();
	skinNorms->SetInputConnection(skinExtractor->GetOutputPort());
	skinNorms->SetFeatureAngle(60.0);

	vtkSmartPointerskinStrip = vtkSmartPointer::New();
	skinStrip->SetInputConnection(skinNorms->GetOutputPort());

	vtkSmartPointerskinMapper = vtkSmartPointer::New();
	skinMapper->SetInputConnection(skinStrip->GetOutputPort());
	skinMapper->ScalarVisibilityOff();

	vtkSmartPointerskinActor = vtkSmartPointer::New();
	skinActor->SetMapper(skinMapper);
	skinActor->GetProperty()->SetDiffuseColor(1, 0.49, 0.25);
	skinActor->GetProperty()->SetSpecular(0.3);
	skinActor->GetProperty()->SetSpecularPower(20);
	skinActor->GetProperty()->SetOpacity(0.5);

	vtkSmartPointerboneExtractor = vtkSmartPointer::New();
	boneExtractor->SetInputConnection(v16->GetOutputPort());
	boneExtractor->SetValue(0, 1150);

	vtkSmartPointerboneNormals = vtkSmartPointer::New();
	boneNormals->SetInputConnection(boneExtractor->GetOutputPort());
	boneNormals->SetFeatureAngle(60.0);

	vtkSmartPointerboneStrip = vtkSmartPointer::New();
	boneStrip->SetInputConnection(boneNormals->GetOutputPort());

	vtkSmartPointerboneMapper = vtkSmartPointer::New();
	boneMapper->SetInputConnection(boneStrip->GetOutputPort());
	boneMapper->ScalarVisibilityOff();

	vtkSmartPointerbone = vtkSmartPointer::New();
	bone->SetMapper(boneMapper);
	bone->GetProperty()->SetDiffuseColor(1, 1, 0.9412);

	vtkSmartPointeroutLineData = vtkSmartPointer::New();
	outLineData->SetInputConnection(v16->GetOutputPort());

	vtkSmartPointer mapOutline = vtkSmartPointer::New();
	mapOutline->SetInputConnection(outLineData->GetOutputPort());

	vtkSmartPointeroutline = vtkSmartPointer::New();
	outline->SetMapper(mapOutline);
	outline->GetProperty()->SetColor(0, 0, 0);

	vtkSmartPointercamera = vtkSmartPointer::New();
	camera->SetViewUp(0, 0, -1);
	camera->SetPosition(0, 1, 0);
	camera->SetFocalPoint(0, 0, 0);
	camera->ComputeViewPlaneNormal();
	camera->Azimuth(30.0);
	camera->Elevation(30.0);

	render->AddActor(outline);
	render->AddActor(skinActor);
	render->AddActor(bone);
	render->SetActiveCamera(camera);
	render->ResetCamera();
	render->SetBackground(0.2, 0.3, 0.4);
	camera->Dolly(1.5);
	render->ResetCameraClippingRange();

	vtkSmartPointerstyle = vtkSmartPointer::New();
	iren->SetInteractorStyle(style);

	iren->Initialize();
	iren->Start();
	
	return 0;
}
VTK皮肤与骨骼抽取_第1张图片

你可能感兴趣的:(VTK)