【问题标题】:How can I display image without CT with pydicom?如何在没有 CT 的情况下使用 pydicom 显示图像?
【发布时间】:2018-04-23 04:45:27
【问题描述】:

如何在没有 CT(轮廓)的情况下使用 pydicom 显示图像?

目前它显示的是图像,但它包括轮廓,我想显示根图像,如果可以的话,没有根图像的轮廓

这是我的参考代码,但我在控制台中测试了搜索

import matplotlib.pyplot as plt
import pydicom
#from pydicom.data import get_testdata_files

PathDicom = "./Dicoms/"
lstFilesDCM = []  # create an empty list
Pattient = []  # create an empty list
for dirName, subdirList, fileList in os.walk(PathDicom):
    for filename in fileList:
        if ".dcm" in filename.lower():  # check whether the file's DICOM
            lstFilesDCM.append(os.path.join(dirName,filename))
            dataset = pydicom.dcmread(os.path.join(dirName,filename))
            print(__doc__)
#            filename = get_testdata_files(os.path.join(dirName,filename))[0]
#            dataset = pydicom.dcmread(filename)

            # Normal mode:
            print()
            print("Filename.........:", filename)
            print("Storage type.....:", dataset.SOPClassUID)
            print()

            pat_name = dataset.PatientName
            display_name = pat_name.family_name + ", " + pat_name.given_name
            print("Patient's name...:", display_name)
            print("Patient id.......:", dataset.PatientID)
            print("Study id.......:", dataset.StudyID)
            print("Modality.........:", dataset.Modality)
            print("Study Date.......:", dataset.StudyDate)
            print("Contour..........:", dataset.dir("contour"))
            #espesor de corte
            print("Slice Thickness..:", dataset.SliceThickness)

            if 'PixelData' in dataset:
                rows = int(dataset.Rows)
                cols = int(dataset.Columns)
                print("Image size.......: {rows:d} x {cols:d}, {size:d} bytes".format(
                    rows=rows, cols=cols, size=len(dataset.PixelData)))
                if 'PixelSpacing' in dataset:
                    print("Pixel spacing....:", dataset.PixelSpacing)

            # use .get() if not sure the item exists, and want a default value if missing
            print("Slice location...:", dataset.get('SliceLocation', "(missing)"))
            #plot the image with contouring
            plt.imshow(dataset.pixel_array, cmap=plt.cm.bone)

【问题讨论】:

    标签: python python-3.x image pydicom


    【解决方案1】:

    我建议您查看dicompyler 以获取有关如何同时显示图像和轮廓的示例。它使用 wxPython 进行显示,但如果需要,您可以将这些概念转换为其他图形库。或者,也许您可​​以根据需要将自定义插件添加到 dicompyler。

    【讨论】:

      猜你喜欢
      • 2022-11-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-03
      • 1970-01-01
      • 2012-01-22
      • 1970-01-01
      相关资源
      最近更新 更多