gpt4 book ai didi

python - 运行时错误 : The following handlers are available to decode the pixel data however they are missing required dependencies: GDCM (req. GDCM)

转载 作者:行者123 更新时间:2023-12-03 14:55:47 28 4
gpt4 key购买 nike

我想将 dcm 文件转换为 png 文件。但是,发生了以下错误:RuntimeError:以下处理程序可用于解码像素数据,但是它们缺少所需的依赖项:GDCM(要求 GDCM)

import cv2
import os
import pydicom

inputdir = 'C:\\data1\\'
outdir = 'C:\\data\\'
#os.mkdir(outdir)

test_list = [ f for f in os.listdir(inputdir)]

for f in test_list: # remove "[:10]" to convert all images
ds = pydicom.read_file(inputdir + f) # read dicom image
img = ds.pixel_array # get image array
cv2.imwrite(outdir + f.replace('.dcm','.png'),img) # write png image

最佳答案

!conda install -c conda-forge gdcm -y
导入 gdcm

关于python - 运行时错误 : The following handlers are available to decode the pixel data however they are missing required dependencies: GDCM (req. GDCM),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56834003/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com