{"id":2175,"date":"2024-04-29T10:43:16","date_gmt":"2024-04-29T02:43:16","guid":{"rendered":"https:\/\/sanlangcode.com\/?p=2175"},"modified":"2024-04-29T10:43:16","modified_gmt":"2024-04-29T02:43:16","slug":"vtk%e5%ae%9e%e7%8e%b0%e5%9b%9b%e8%a7%86%e5%9b%be%e6%b8%b2%e6%9f%93dcm%e5%ba%8f%e5%88%97%e5%8c%96%e6%95%b0%e6%8d%ae%e9%9b%86","status":"publish","type":"post","link":"https:\/\/sanlangcode.com\/index.php\/2024\/04\/29\/vtk%e5%ae%9e%e7%8e%b0%e5%9b%9b%e8%a7%86%e5%9b%be%e6%b8%b2%e6%9f%93dcm%e5%ba%8f%e5%88%97%e5%8c%96%e6%95%b0%e6%8d%ae%e9%9b%86\/","title":{"rendered":"\u4f7f\u7528VTK\u5b9e\u73b0\u56db\u89c6\u56fe\u6e32\u67d3dcm\u5e8f\u5217\u5316\u6570\u636e\u96c6"},"content":{"rendered":"\n<p>\u4f7f\u7528 VTK\uff08Visualization Toolkit\uff09\u5e93\u6765\u53ef\u89c6\u5316 DICOM \u56fe\u50cf\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li><strong>\u4e3b\u8981\u4f5c\u7528<\/strong>\uff1a<ul><li>\u52a0\u8f7d DICOM \u56fe\u50cf\u5e8f\u5217\u3002<\/li><li>\u521b\u5efa\u56db\u4e2a\u6e32\u67d3\u5668\uff0c\u5176\u4e2d\u4e09\u4e2a\u7528\u4e8e\u663e\u793a\u4e0d\u540c\u65b9\u5411\u7684\u56fe\u50cf\u5e73\u9762\uff0c\u7b2c\u56db\u4e2a\u7528\u4e8e\u663e\u793a\u6574\u4e2a\u6570\u636e\u96c6\u7684\u8f6e\u5ed3\u3002<\/li><li>\u5728\u4e09\u4e2a\u65b9\u5411\u4e0a\u521b\u5efa\u4ea4\u4e92\u5f0f\u56fe\u50cf\u5e73\u9762\u5c0f\u90e8\u4ef6\uff0c\u5141\u8bb8\u7528\u6237\u5728\u56fe\u50cf\u4e0a\u8fdb\u884c\u5207\u7247\u6d4f\u89c8\u3002<\/li><li>\u4f7f\u7528\u4e09\u4e2a\u4ea4\u4e92\u5f0f\u5c0f\u90e8\u4ef6\u548c\u4e00\u4e2a\u9f20\u6807\u4ea4\u4e92\u5668\u6765\u63a7\u5236\u6e32\u67d3\u7a97\u53e3\u7684\u4ea4\u4e92\u884c\u4e3a\u3002<\/li><\/ul><\/li><li><strong>\u5b9e\u73b0\u903b\u8f91<\/strong>\uff1a<ul><li>\u9996\u5148\uff0c\u901a\u8fc7 <code>vtkDICOMImageReader<\/code> \u7c7b\u52a0\u8f7d DICOM \u56fe\u50cf\u5e8f\u5217\u3002<\/li><li>\u7136\u540e\uff0c\u521b\u5efa\u4e00\u4e2a\u6e32\u67d3\u7a97\u53e3\u548c\u56db\u4e2a\u6e32\u67d3\u5668\uff0c\u5176\u4e2d\u4e00\u4e2a\u7528\u4e8e\u663e\u793a\u8f6e\u5ed3\uff0c\u53e6\u5916\u4e09\u4e2a\u7528\u4e8e\u663e\u793a\u4e0d\u540c\u65b9\u5411\u7684\u56fe\u50cf\u5e73\u9762\u3002<\/li><li>\u901a\u8fc7 <code>vtkImagePlaneWidget<\/code> \u7c7b\u521b\u5efa\u4e09\u4e2a\u4ea4\u4e92\u5f0f\u56fe\u50cf\u5e73\u9762\u5c0f\u90e8\u4ef6\uff0c\u7528\u4e8e\u5728\u4e09\u4e2a\u65b9\u5411\u4e0a\u663e\u793a\u5207\u7247\u3002<\/li><li>\u521b\u5efa\u4e00\u4e2a\u7528\u4e8e\u5904\u7406\u4ea4\u4e92\u4e8b\u4ef6\u7684\u81ea\u5b9a\u4e49\u56de\u8c03\u7c7b <code>vtkResliceCursorCallback<\/code>\u3002\u8be5\u7c7b\u7528\u4e8e\u786e\u4fdd\u5728\u4ea4\u4e92\u64cd\u4f5c\u671f\u95f4\u4e09\u4e2a\u56fe\u50cf\u5e73\u9762\u4e4b\u95f4\u7684\u540c\u6b65\u66f4\u65b0\u3002<\/li><li>\u521b\u5efa\u4e00\u4e2a\u7528\u4e8e\u7ed8\u5236\u5207\u7247\u7ebf\u7684 <code>vtkResliceCursorWidget<\/code> \u548c <code>vtkResliceCursorLineRepresentation<\/code>\u3002<\/li><li>\u8bbe\u7f6e\u6e32\u67d3\u5668\u7684\u80cc\u666f\u989c\u8272\uff0c\u5e76\u5c06\u8f6e\u5ed3\u548c\u56fe\u50cf\u5e73\u9762\u6dfb\u52a0\u5230\u76f8\u5e94\u7684\u6e32\u67d3\u5668\u4e2d\u3002<\/li><li>\u8bbe\u7f6e\u4ea4\u4e92\u5668\u548c\u4ea4\u4e92\u6837\u5f0f\uff0c\u542f\u52a8\u4ea4\u4e92\u4e8b\u4ef6\u5faa\u73af\u4ee5\u7b49\u5f85\u7528\u6237\u4ea4\u4e92\u3002<\/li><\/ul><\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image size-full is-resized is-style-default\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/sanlangcode.com\/wp-content\/uploads\/2024\/04\/image-1.png\" alt=\"\" class=\"wp-image-2177\" width=\"837\" height=\"694\"\/><\/figure>\n\n\n\n<p><strong>\u6e32\u67d3\u903b\u8f91\u4e3b\u8981\u6d89\u53ca\u4ee5\u4e0b\u51e0\u4e2a\u65b9\u9762\uff1a<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\"><li><strong>\u6e32\u67d3\u5668\u548c\u6e32\u67d3\u7a97\u53e3\u7684\u521b\u5efa<\/strong>\uff1a<ul><li>\u901a\u8fc7 <code>vtkRenderer<\/code> \u7c7b\u521b\u5efa\u56db\u4e2a\u6e32\u67d3\u5668\u5bf9\u8c61\uff0c\u5176\u4e2d\u4e09\u4e2a\u7528\u4e8e\u663e\u793a\u56fe\u50cf\u5e73\u9762\uff0c\u4e00\u4e2a\u7528\u4e8e\u663e\u793a\u8f6e\u5ed3\u3002<\/li><li>\u4f7f\u7528 <code>vtkRenderWindow<\/code> \u7c7b\u521b\u5efa\u4e00\u4e2a\u6e32\u67d3\u7a97\u53e3\u5bf9\u8c61\uff0c\u5e76\u5c06\u56db\u4e2a\u6e32\u67d3\u5668\u6dfb\u52a0\u5230\u8be5\u7a97\u53e3\u4e2d\u3002<\/li><\/ul><\/li><li><strong>DICOM \u56fe\u50cf\u52a0\u8f7d\u548c\u6570\u636e\u5904\u7406<\/strong>\uff1a<ul><li>\u4f7f\u7528 <code>vtkDICOMImageReader<\/code> \u7c7b\u52a0\u8f7d DICOM \u56fe\u50cf\u5e8f\u5217\u3002<\/li><li>\u521b\u5efa\u4e00\u4e2a <code>vtkPolyDataMapper<\/code> \u5bf9\u8c61\uff0c\u5e76\u5c06 DICOM \u56fe\u50cf\u6570\u636e\u8fde\u63a5\u5230\u8be5 Mapper \u4e0a\u3002<\/li><\/ul><\/li><li><strong>\u4ea4\u4e92\u5f0f\u56fe\u50cf\u5e73\u9762\u5c0f\u90e8\u4ef6\u7684\u521b\u5efa\u548c\u914d\u7f6e<\/strong>\uff1a<ul><li>\u4f7f\u7528 <code>vtkImagePlaneWidget<\/code> \u7c7b\u521b\u5efa\u4e09\u4e2a\u4ea4\u4e92\u5f0f\u56fe\u50cf\u5e73\u9762\u5c0f\u90e8\u4ef6\uff0c\u5206\u522b\u7528\u4e8e\u5728 X\u3001Y\u3001Z \u65b9\u5411\u4e0a\u663e\u793a\u56fe\u50cf\u5207\u7247\u3002<\/li><li>\u9488\u5bf9\u6bcf\u4e2a\u56fe\u50cf\u5e73\u9762\u5c0f\u90e8\u4ef6\uff0c\u8bbe\u7f6e\u4ea4\u4e92\u5668\u3001Picker\u3001PlaneProperty\u3001TexturePlaneProperty \u7b49\u5c5e\u6027\uff0c\u5e76\u5c06\u5176\u8fde\u63a5\u5230 DICOM \u56fe\u50cf\u6570\u636e\u4e0a\u3002<\/li><\/ul><\/li><li><strong>\u5207\u7247\u7ebf\u548c\u5207\u7247\u7ebf\u8868\u793a\u7684\u521b\u5efa\u548c\u914d\u7f6e<\/strong>\uff1a<ul><li>\u4f7f\u7528 <code>vtkResliceCursorWidget<\/code> \u548c <code>vtkResliceCursorLineRepresentation<\/code> \u7c7b\u521b\u5efa\u4e09\u4e2a\u5207\u7247\u7ebf\u5c0f\u90e8\u4ef6\u548c\u8868\u793a\u5bf9\u8c61\u3002<\/li><li>\u8bbe\u7f6e\u6bcf\u4e2a\u5207\u7247\u7ebf\u7684\u9ed8\u8ba4\u6e32\u67d3\u5668\u3001\u5207\u7247\u7ebf\u7684\u5c5e\u6027\u4ee5\u53ca\u5173\u8054\u7684 DICOM \u56fe\u50cf\u6570\u636e\u3002<\/li><\/ul><\/li><li><strong>\u6e32\u67d3\u5668\u7684\u8bbe\u7f6e\u548c\u5e03\u5c40<\/strong>\uff1a<ul><li>\u4e3a\u6bcf\u4e2a\u6e32\u67d3\u5668\u8bbe\u7f6e\u4e0d\u540c\u7684\u80cc\u666f\u989c\u8272\u3002<\/li><li>\u5c06\u8f6e\u5ed3\u6e32\u67d3\u5668\u4e2d\u7684\u8f6e\u5ed3 Actor \u6dfb\u52a0\u5230\u76f8\u5e94\u7684\u6e32\u67d3\u5668\u4e2d\u3002<\/li><li>\u914d\u7f6e\u56db\u4e2a\u6e32\u67d3\u5668\u7684\u89c6\u53e3\uff0c\u4ee5\u4fbf\u5728\u6e32\u67d3\u7a97\u53e3\u4e2d\u6b63\u786e\u5e03\u5c40\u5b83\u4eec\u3002<\/li><\/ul><\/li><li><strong>\u4ea4\u4e92\u5668\u548c\u4ea4\u4e92\u6837\u5f0f\u7684\u8bbe\u7f6e<\/strong>\uff1a<ul><li>\u4f7f\u7528 <code>vtkRenderWindowInteractor<\/code> \u7c7b\u521b\u5efa\u4e00\u4e2a\u4ea4\u4e92\u5668\u5bf9\u8c61\uff0c\u5e76\u5c06\u5176\u8fde\u63a5\u5230\u6e32\u67d3\u7a97\u53e3\u4e2d\u3002<\/li><li>\u521b\u5efa\u4e00\u4e2a <code>vtkCellPicker<\/code> \u5bf9\u8c61\uff0c\u7528\u4e8e\u6355\u83b7\u7528\u6237\u4ea4\u4e92\u64cd\u4f5c\u3002<\/li><li>\u4f7f\u7528 <code>vtkInteractorStyleImage<\/code> \u7c7b\u6765\u5b9a\u4e49\u4ea4\u4e92\u6837\u5f0f\uff0c\u4f7f\u7528\u6237\u80fd\u591f\u5728\u56fe\u50cf\u4e0a\u6267\u884c\u5207\u7247\u6d4f\u89c8\u64cd\u4f5c\u3002<\/li><\/ul><\/li><li><strong>\u4e8b\u4ef6\u5faa\u73af\u7684\u542f\u52a8<\/strong>\uff1a<ul><li>\u542f\u52a8\u4ea4\u4e92\u5668\u7684\u4e8b\u4ef6\u5faa\u73af\uff0c\u7b49\u5f85\u7528\u6237\u7684\u4ea4\u4e92\u64cd\u4f5c\u3002<\/li><li>\u5f53\u7528\u6237\u4e0e\u56fe\u50cf\u4ea4\u4e92\u65f6\uff0c\u6839\u636e\u7528\u6237\u7684\u64cd\u4f5c\u66f4\u65b0\u56fe\u50cf\u5e73\u9762\u7684\u663e\u793a\u3001\u5207\u7247\u7ebf\u7684\u4f4d\u7f6e\u4ee5\u53ca\u6574\u4e2a\u6e32\u67d3\u7a97\u53e3\u7684\u89c6\u56fe\u3002<\/li><\/ul><\/li><\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>#include \"vtkSmartPointer.h\"\n#include \"vtkActor.h\"\n#include \"vtkCamera.h\"\n#include \"vtkCellPicker.h\"\n#include \"vtkCommand.h\"\n#include \"vtkImageActor.h\"\n#include \"vtkImageReslice.h\"\n#include \"vtkInteractorStyleImage.h\"\n#include \"vtkImageMapToColors.h\"\n#include \"vtkImagePlaneWidget.h\"\n#include \"vtkImageReader.h\"\n#include \"vtkInteractorEventRecorder.h\"\n#include \"vtkLookupTable.h\"\n#include \"vtkOutlineFilter.h\"\n#include \"vtkDICOMImageReader.h\"\n#include \"vtkPolyDataMapper.h\"\n#include \"vtkProperty.h\"\n#include \"vtkRenderWindow.h\"\n#include \"vtkRenderWindowInteractor.h\"\n#include \"vtkRenderer.h\"\n#include \"vtkImageData.h\"\n#include \"vtkPointData.h\"\n#include \"vtkPlaneSource.h\"\n#include \"vtkPlane.h\"\n#include \"vtkResliceCursorActor.h\"\n#include \"vtkResliceCursorPolyDataAlgorithm.h\"\n#include \"vtkResliceCursor.h\"\n#include \"vtkResliceCursorWidget.h\"\n#include \"vtkResliceCursorLineRepresentation.h\"\n#include \"vtkBiDimensionalWidget.h\"\n#include\"vtkAutoInit.h\"\n#include\"vtkAxesActor.h\"\n#include\"vtkTransform.h\"\n#include\"vtkTextActor.h\"\n#include\"vtkProperty2D.h\"\n\nVTK_MODULE_INIT(vtkRenderingOpenGL2);\nVTK_MODULE_INIT(vtkInteractionStyle);\nVTK_MODULE_INIT(vtkRenderingFreeType);\nVTK_MODULE_INIT(vtkRenderingVolumeOpenGL2);\n\nclass vtkResliceCursorCallback : public vtkCommand\n{\npublic:\n    static vtkResliceCursorCallback* New()\n    {\n        return new vtkResliceCursorCallback;\n    }\n    void Execute(vtkObject* caller, unsigned long, void* callData) override\n    {\n        vtkImagePlaneWidget* ipw = dynamic_cast&lt;vtkImagePlaneWidget*>(caller);\n        if (ipw)\n        {\n            double* wl = static_cast&lt;double*>(callData);\n\n            if (ipw == this->IPW&#91;0])\n            {\n                this->IPW&#91;1]->SetWindowLevel(wl&#91;0], wl&#91;1], 1);\n                this->IPW&#91;2]->SetWindowLevel(wl&#91;0], wl&#91;1], 1);\n            }\n            else if (ipw == this->IPW&#91;1])\n            {\n                this->IPW&#91;0]->SetWindowLevel(wl&#91;0], wl&#91;1], 1);\n                this->IPW&#91;2]->SetWindowLevel(wl&#91;0], wl&#91;1], 1);\n            }\n            else if (ipw == this->IPW&#91;2])\n            {\n                this->IPW&#91;0]->SetWindowLevel(wl&#91;0], wl&#91;1], 1);\n                this->IPW&#91;1]->SetWindowLevel(wl&#91;0], wl&#91;1], 1);\n            }\n        }\n        vtkResliceCursorWidget* rcw = dynamic_cast&lt;vtkResliceCursorWidget*>(caller);\n        if (rcw)\n        {\n            vtkResliceCursorLineRepresentation* rep = dynamic_cast&lt;vtkResliceCursorLineRepresentation*>(rcw->GetRepresentation());\n            vtkResliceCursor* rc = rep->GetResliceCursorActor()->GetCursorAlgorithm()->GetResliceCursor();\n            for (int i = 0; i &lt; 3; i++)\n            {\n                vtkPlaneSource* ps = static_cast&lt;vtkPlaneSource*>(this->IPW&#91;i]->GetPolyDataAlgorithm());\n                ps->SetNormal(rc->GetPlane(i)->GetNormal());\n                ps->SetCenter(rc->GetPlane(i)->GetOrigin());\n                this->IPW&#91;i]->UpdatePlacement();\n            }\n        }\n        this->RCW&#91;0]->Render();\n    }\n    vtkResliceCursorCallback() {}\n    vtkImagePlaneWidget* IPW&#91;3];\n    vtkResliceCursorWidget* RCW&#91;3];\n};\n\nint main()\n{\n    vtkSmartPointer&lt;vtkDICOMImageReader> reader = vtkSmartPointer&lt;vtkDICOMImageReader>::New();\n    reader->SetDirectoryName(\"C:\/Users\/DeepA\/Desktop\/CTA_Cardio\");\n    reader->Update();\n   \n    vtkSmartPointer&lt;vtkPolyDataMapper> outlineMapper = vtkSmartPointer&lt;vtkPolyDataMapper>::New();\n    outlineMapper->SetInputConnection(reader->GetOutputPort());\n\n    vtkSmartPointer&lt;vtkActor> outlineActor = vtkSmartPointer&lt;vtkActor>::New();\n    outlineActor->SetMapper(outlineMapper);\n\n    vtkSmartPointer&lt;vtkRenderer> ren&#91;4];\n    vtkSmartPointer&lt;vtkRenderWindow> renWin = vtkSmartPointer&lt;vtkRenderWindow>::New();\n    renWin->SetMultiSamples(0);\n\n    for (int i = 0; i &lt; 4; i++)\n    {\n        ren&#91;i] = vtkSmartPointer&lt;vtkRenderer>::New();\n        renWin->AddRenderer(ren&#91;i]);\n    }\n\n    vtkSmartPointer&lt;vtkRenderWindowInteractor> iren = vtkSmartPointer&lt;vtkRenderWindowInteractor>::New();\n    iren->SetRenderWindow(renWin);\n\n    vtkSmartPointer&lt;vtkCellPicker> picker = vtkSmartPointer&lt;vtkCellPicker>::New();\n    picker->SetTolerance(0.005);\n\n    vtkSmartPointer&lt;vtkProperty> ipwProp = vtkSmartPointer&lt;vtkProperty>::New();\n\n    vtkSmartPointer&lt;vtkImagePlaneWidget> planeWidget&#91;3];\n    int imageDims&#91;3];\n    reader->GetOutput()->GetDimensions(imageDims);\n\n    for (int i = 0; i &lt; 3; i++)\n    {\n        planeWidget&#91;i] = vtkSmartPointer&lt;vtkImagePlaneWidget>::New();\n        planeWidget&#91;i]->SetInteractor(iren);\n        planeWidget&#91;i]->SetPicker(picker);\n        planeWidget&#91;i]->RestrictPlaneToVolumeOn();\n        double color&#91;3] = { 0, 0, 0 };\n        color&#91;i] = 1;\n        planeWidget&#91;i]->GetPlaneProperty()->SetColor(color);\n        planeWidget&#91;i]->SetTexturePlaneProperty(ipwProp);\n        planeWidget&#91;i]->TextureInterpolateOff();\n        planeWidget&#91;i]->SetResliceInterpolateToLinear();\n        planeWidget&#91;i]->SetInputConnection(reader->GetOutputPort());\n        planeWidget&#91;i]->SetPlaneOrientation(i);\n        planeWidget&#91;i]->SetSliceIndex(imageDims&#91;i] \/ 2);\n        planeWidget&#91;i]->DisplayTextOn();\n        planeWidget&#91;i]->SetDefaultRenderer(ren&#91;3]);\n        planeWidget&#91;i]->SetWindowLevel(1358, -27);\n        planeWidget&#91;i]->On();\n        planeWidget&#91;i]->InteractionOn();\n    }\n\n    planeWidget&#91;1]->SetLookupTable(planeWidget&#91;0]->GetLookupTable());\n    planeWidget&#91;2]->SetLookupTable(planeWidget&#91;0]->GetLookupTable());\n\n    vtkSmartPointer&lt;vtkResliceCursorCallback> cbk = vtkSmartPointer&lt;vtkResliceCursorCallback>::New();\n    vtkSmartPointer&lt; vtkResliceCursor > resliceCursor = vtkSmartPointer&lt; vtkResliceCursor >::New();\n    resliceCursor->SetCenter(reader->GetOutput()->GetCenter());\n    resliceCursor->SetThickMode(0);\n    resliceCursor->SetThickness(10, 10, 10);\n    resliceCursor->SetImage(reader->GetOutput());\n\n    vtkSmartPointer&lt; vtkResliceCursorWidget > resliceCursorWidget&#91;3];\n    vtkSmartPointer&lt; vtkResliceCursorLineRepresentation > resliceCursorRep&#91;3];\n\n    double viewUp&#91;3]&#91;3] = { { 0, 0, -1 }, { 0, 0, 1 }, { 0, 1, 0 } };\n    for (int i = 0; i &lt; 3; i++)\n    {\n        resliceCursorWidget&#91;i] = vtkSmartPointer&lt; vtkResliceCursorWidget >::New();\n        resliceCursorWidget&#91;i]->SetInteractor(iren);\n\n        resliceCursorRep&#91;i] = vtkSmartPointer&lt; vtkResliceCursorLineRepresentation >::New();\n        resliceCursorWidget&#91;i]->SetRepresentation(resliceCursorRep&#91;i]);\n        resliceCursorRep&#91;i]->GetResliceCursorActor()->GetCursorAlgorithm()->SetResliceCursor(resliceCursor);\n        resliceCursorRep&#91;i]->GetResliceCursorActor()->GetCursorAlgorithm()->SetReslicePlaneNormal(i);\n\n        const double minVal = reader->GetOutput()->GetScalarRange()&#91;0];\n        if (vtkImageReslice* reslice = vtkImageReslice::SafeDownCast(resliceCursorRep&#91;i]->GetReslice()))\n        {\n            reslice->SetBackgroundColor(minVal, minVal, minVal, minVal);\n        }\n\n        resliceCursorWidget&#91;i]->SetDefaultRenderer(ren&#91;i]);\n        resliceCursorWidget&#91;i]->SetEnabled(1);\n\n        ren&#91;i]->GetActiveCamera()->SetFocalPoint(0, 0, 0);\n        double camPos&#91;3] = { 0, 0, 0 };\n        camPos&#91;i] = 1;\n        ren&#91;i]->GetActiveCamera()->SetPosition(camPos);\n        ren&#91;i]->GetActiveCamera()->ParallelProjectionOn();\n        ren&#91;i]->GetActiveCamera()->SetViewUp(viewUp&#91;i]&#91;0], viewUp&#91;i]&#91;1], viewUp&#91;i]&#91;2]);\n        ren&#91;i]->ResetCamera();\n        cbk->IPW&#91;i] = planeWidget&#91;i];\n        cbk->RCW&#91;i] = resliceCursorWidget&#91;i];\n        resliceCursorWidget&#91;i]->AddObserver(vtkResliceCursorWidget::ResliceAxesChangedEvent, cbk);\n        double range&#91;2];\n        reader->GetOutput()->GetScalarRange(range);\n        resliceCursorRep&#91;i]->SetWindowLevel(range&#91;1] - range&#91;0], (range&#91;0] + range&#91;1]) \/ 2.0);\n        planeWidget&#91;i]->SetWindowLevel(range&#91;1] - range&#91;0], (range&#91;0] + range&#91;1]) \/ 2.0);\n        resliceCursorRep&#91;i]->SetLookupTable(resliceCursorRep&#91;0]->GetLookupTable());\n        planeWidget&#91;i]->GetColorMap()->SetLookupTable(resliceCursorRep&#91;0]->GetLookupTable());\n    }\n  \n    ren&#91;0]->SetBackground(0.3, 0.1, 0.1);\n    ren&#91;1]->SetBackground(0.1, 0.3, 0.1);\n    ren&#91;2]->SetBackground(0.1, 0.1, 0.3);\n    ren&#91;3]->AddActor(outlineActor);\n    ren&#91;3]->SetBackground(0.1, 0.1, 0.1);\n    renWin->SetSize(900, 900);\n\n    ren&#91;0]->SetViewport(0, 0, 0.5, 0.5);\n    ren&#91;1]->SetViewport(0.5, 0, 1, 0.5);\n    ren&#91;2]->SetViewport(0, 0.5, 0.5, 1);\n    ren&#91;3]->SetViewport(0.5, 0.5, 1, 1);\n    renWin->Render();\n      \n    ren&#91;3]->GetActiveCamera()->Elevation(110);\n    ren&#91;3]->GetActiveCamera()->SetViewUp(0, 0, -1);\n    ren&#91;3]->GetActiveCamera()->Azimuth(45);\n    ren&#91;3]->GetActiveCamera()->Dolly(1.15);\n    ren&#91;3]->ResetCameraClippingRange();\n\n    vtkSmartPointer&lt; vtkInteractorStyleImage > style = vtkSmartPointer&lt; vtkInteractorStyleImage >::New();\n\n    iren->SetInteractorStyle(style);\n    iren->Initialize();\n    iren->Start();\n    return EXIT_SUCCESS;\n}<\/code><\/pre>\n\n\n\n<p><strong>\u4ea4\u4e92\u903b\u8f91\u4e3b\u8981\u5305\u62ec\u4ee5\u4e0b\u51e0\u4e2a\u65b9\u9762\uff1a<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\"><li><strong>DICOM \u56fe\u50cf\u52a0\u8f7d\u548c\u521d\u59cb\u663e\u793a<\/strong>\uff1a<ul><li>\u901a\u8fc7 <code>vtkDICOMImageReader<\/code> \u52a0\u8f7d DICOM \u56fe\u50cf\u5e8f\u5217\uff0c\u5e76\u4f7f\u7528 <code>vtkImagePlaneWidget<\/code> \u5728\u4e09\u4e2a\u65b9\u5411\u4e0a\u663e\u793a\u521d\u59cb\u7684\u5207\u7247\u56fe\u50cf\u3002<\/li><\/ul><\/li><li><strong>\u5207\u7247\u6d4f\u89c8<\/strong>\uff1a<ul><li>\u7528\u6237\u53ef\u4ee5\u901a\u8fc7\u4ea4\u4e92\u64cd\u4f5c\uff0c\u5728 X\u3001Y\u3001Z \u4e09\u4e2a\u65b9\u5411\u4e0a\u6d4f\u89c8\u5207\u7247\u56fe\u50cf\uff0c\u901a\u8fc7\u79fb\u52a8\u56fe\u50cf\u5e73\u9762\u5c0f\u90e8\u4ef6\u6765\u6539\u53d8\u5207\u7247\u4f4d\u7f6e\u3002<\/li><\/ul><\/li><li><strong>\u7a97\u5bbd\u7a97\u4f4d\u8c03\u6574<\/strong>\uff1a<ul><li>\u7528\u6237\u53ef\u4ee5\u901a\u8fc7\u4ea4\u4e92\u64cd\u4f5c\uff0c\u8c03\u6574\u56fe\u50cf\u7684\u7a97\u5bbd\u548c\u7a97\u4f4d\u3002\u5728\u56de\u8c03\u51fd\u6570\u4e2d\uff0c\u5f53\u4e00\u4e2a\u56fe\u50cf\u5e73\u9762\u5c0f\u90e8\u4ef6\u7684\u7a97\u5bbd\u7a97\u4f4d\u53d1\u751f\u53d8\u5316\u65f6\uff0c\u5176\u4ed6\u5e73\u9762\u5c0f\u90e8\u4ef6\u7684\u7a97\u5bbd\u7a97\u4f4d\u4e5f\u4f1a\u968f\u4e4b\u6539\u53d8\u3002<\/li><\/ul><\/li><li><strong>\u5207\u7247\u7ebf\u4f4d\u7f6e\u540c\u6b65<\/strong>\uff1a<ul><li>\u901a\u8fc7 <code>vtkResliceCursorCallback<\/code> \u7c7b\u4e2d\u7684\u56de\u8c03\u51fd\u6570\uff0c\u5b9e\u73b0\u4e86\u5207\u7247\u7ebf\u4f4d\u7f6e\u7684\u540c\u6b65\u3002\u5f53\u4e00\u4e2a\u5207\u7247\u7ebf\u7684\u4f4d\u7f6e\u53d1\u751f\u53d8\u5316\u65f6\uff0c\u5176\u4ed6\u5207\u7247\u7ebf\u7684\u4f4d\u7f6e\u4e5f\u4f1a\u76f8\u5e94\u5730\u6539\u53d8\uff0c\u4ee5\u4fdd\u6301\u5207\u7247\u7ebf\u7684\u4f4d\u7f6e\u540c\u6b65\u3002<\/li><\/ul><\/li><li><strong>\u6e32\u67d3\u5668\u89c6\u56fe\u8c03\u6574<\/strong>\uff1a<ul><li>\u5728\u521d\u59cb\u5316\u9636\u6bb5\uff0c\u901a\u8fc7\u8bbe\u7f6e\u4e0d\u540c\u6e32\u67d3\u5668\u7684\u89c6\u53e3\u6765\u5b9e\u73b0\u591a\u89c6\u56fe\u5e03\u5c40\u3002\u5728\u56db\u4e2a\u6e32\u67d3\u5668\u4e2d\uff0c\u4e09\u4e2a\u7528\u4e8e\u663e\u793a\u56fe\u50cf\u5207\u7247\uff0c\u4e00\u4e2a\u7528\u4e8e\u663e\u793a\u56fe\u50cf\u7684\u8f6e\u5ed3\u3002<\/li><\/ul><\/li><li><strong>\u4ea4\u4e92\u5668\u8bbe\u7f6e<\/strong>\uff1a<ul><li>\u4f7f\u7528 <code>vtkRenderWindowInteractor<\/code> \u7c7b\u521b\u5efa\u4e00\u4e2a\u4ea4\u4e92\u5668\u5bf9\u8c61\uff0c\u5e76\u4f7f\u7528 <code>vtkInteractorStyleImage<\/code> \u7c7b\u6765\u5b9a\u4e49\u4ea4\u4e92\u6837\u5f0f\u3002\u8fd9\u4f7f\u7528\u6237\u53ef\u4ee5\u5728\u56fe\u50cf\u4e0a\u6267\u884c\u5207\u7247\u6d4f\u89c8\u64cd\u4f5c\u3002<\/li><\/ul><\/li><li><strong>\u4e8b\u4ef6\u5904\u7406<\/strong>\uff1a<ul><li>\u5f53\u7528\u6237\u4e0e\u56fe\u50cf\u8fdb\u884c\u4ea4\u4e92\u64cd\u4f5c\u65f6\uff0c\u4f8b\u5982\u79fb\u52a8\u3001\u7f29\u653e\u3001\u65cb\u8f6c\u7b49\uff0c\u4ea4\u4e92\u5668\u4f1a\u6355\u83b7\u76f8\u5e94\u7684\u4e8b\u4ef6\uff0c\u5e76\u89e6\u53d1\u76f8\u5e94\u7684\u64cd\u4f5c\u3002\u4f8b\u5982\uff0c\u5f53\u7528\u6237\u79fb\u52a8\u56fe\u50cf\u5e73\u9762\u5c0f\u90e8\u4ef6\u65f6\uff0c\u4f1a\u89e6\u53d1\u76f8\u5e94\u7684\u5207\u7247\u6d4f\u89c8\u64cd\u4f5c\u3002<\/li><\/ul><\/li><li><strong>\u4e8b\u4ef6\u5faa\u73af<\/strong>\uff1a<ul><li>\u542f\u52a8\u4ea4\u4e92\u5668\u7684\u4e8b\u4ef6\u5faa\u73af\uff0c\u4f7f\u7a0b\u5e8f\u80fd\u591f\u6301\u7eed\u54cd\u5e94\u7528\u6237\u7684\u4ea4\u4e92\u64cd\u4f5c\uff0c\u76f4\u5230\u7528\u6237\u9000\u51fa\u3002<\/li><\/ul><\/li><\/ol>\n","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528 VTK\uff08Visualiza&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":2176,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[45,42,34],"tags":[],"class_list":["post-2175","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-c-2","category-vtk","category-34"],"_links":{"self":[{"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/posts\/2175","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/comments?post=2175"}],"version-history":[{"count":0,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/posts\/2175\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/media?parent=2175"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/categories?post=2175"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/tags?post=2175"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}