vtk实战(十三)——读取DICOM影像文件

来源:互联网 发布:网络是把双刃剑章郑 编辑:程序博客网 时间:2024/05/01 00:18

DICOM(Digital Imaging and Communications in Medicine)即医学数字成像和通信,是医学图像和相关信息的国际标准。
本例主要使用vtkDICOMImageReader()对DICOM图像进行操作。
注意:vtkDICOMImageReader()只能对DICOM原始文件进行操作,不处理多帧DICOM数据集。

int main(){    std::string folder = "digest_article";    vtkSmartPointer<vtkDICOMImageReader> reader =        vtkSmartPointer<vtkDICOMImageReader>::New();    reader->SetDirectoryName(folder.c_str());    reader->Update();    vtkSmartPointer<vtkImageViewer2> imageViewer =        vtkSmartPointer<vtkImageViewer2>::New();    imageViewer->SetInputConnection(reader->GetOutputPort());    vtkSmartPointer<vtkTextProperty> sliceTextProp = vtkSmartPointer<vtkTextProperty>::New();    sliceTextProp->SetFontFamilyToCourier();    sliceTextProp->SetFontSize(20);    sliceTextProp->SetVerticalJustificationToBottom();    sliceTextProp->SetJustificationToLeft();    vtkSmartPointer<vtkTextMapper> sliceTextMapper = vtkSmartPointer<vtkTextMapper>::New();    std::string msg = StatusMessage::Format(imageViewer->GetSliceMin(), imageViewer->GetSliceMax());    sliceTextMapper->SetInput(msg.c_str());    sliceTextMapper->SetTextProperty(sliceTextProp);    vtkSmartPointer<vtkActor2D> sliceTextActor = vtkSmartPointer<vtkActor2D>::New();    sliceTextActor->SetMapper(sliceTextMapper);    sliceTextActor->SetPosition(15, 10);    vtkSmartPointer<vtkTextProperty> usageTextProp = vtkSmartPointer<vtkTextProperty>::New();    usageTextProp->SetFontFamilyToCourier();    usageTextProp->SetFontSize(14);    usageTextProp->SetVerticalJustificationToTop();    usageTextProp->SetJustificationToLeft();    vtkSmartPointer<vtkTextMapper> usageTextMapper = vtkSmartPointer<vtkTextMapper>::New();    usageTextMapper->SetInput("- Slice with mouse wheel\n  or Up/Down-Key\n- Zoom with pressed right\n  mouse button while dragging");    usageTextMapper->SetTextProperty(usageTextProp);    vtkSmartPointer<vtkActor2D> usageTextActor = vtkSmartPointer<vtkActor2D>::New();    usageTextActor->SetMapper(usageTextMapper);    usageTextActor->GetPositionCoordinate()->SetCoordinateSystemToNormalizedDisplay();    usageTextActor->GetPositionCoordinate()->SetValue(0.05, 0.95);    vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =        vtkSmartPointer<vtkRenderWindowInteractor>::New();    vtkSmartPointer<myVtkInteractorStyleImage> myInteractorStyle =        vtkSmartPointer<myVtkInteractorStyleImage>::New();    myInteractorStyle->SetImageViewer(imageViewer);    myInteractorStyle->SetStatusMapper(sliceTextMapper);    imageViewer->SetupInteractor(renderWindowInteractor);    renderWindowInteractor->SetInteractorStyle(myInteractorStyle);    imageViewer->GetRenderer()->AddActor2D(sliceTextActor);    imageViewer->GetRenderer()->AddActor2D(usageTextActor);    imageViewer->Render();    imageViewer->GetRenderer()->ResetCamera();    imageViewer->Render();    renderWindowInteractor->Start();    return 0;}

运行结果
代码链接:http://pan.baidu.com/s/1pLSWTIj

0 0