Because of the project, I came into contact with DICOM file of medical image. VTK just started to see, here is just its simplest read display function. The VTK library is used here. You can install it by yourself.
The code is attached below:
from vtk import * # reader the dicom file reader = vtkDICOMImageReader() reader.SetDataByteOrderToLittleEndian() reader.SetFileName("00efb2fedf64b867a36031a394e5855a.dcm") reader.Update() # show the dicom flie imageViewer = vtkImageViewer2() imageViewer.SetInputConnection(reader.GetOutputPort()) renderWindowInteractor = vtkRenderWindowInteractor() imageViewer.SetupInteractor(renderWindowInteractor) imageViewer.Render() imageViewer.GetRenderer().ResetCamera() imageViewer.Render() renderWindowInteractor.Start()
Run the program to get the display
DICOM image display can be set window width, window level, is still learning to try, if the effect is good, then update.
The above Python VTK read and display DICOM file example is the whole content shared by Xiaobian. I hope it can give you a reference, and I hope you can support developer more.