1. 遇到无法将dcm格式转成jpg的错误
报错:AttributeError: module ‘scipy.misc’ has no attribute ‘imsave’
【解决】
删除:import scipy.misc
改成: import imageio
删除:save_image = scipy.misc.imsave(out_path, DATA)
改成:save_image = imageio.imsave(out_path, DATA)
2. dcm转成jpg格式后,图像全黑的问题
当时的代码:
ds = pydicom.read_file(dcm_path)
img = ds.pixel_array # Extract image information
imageio.imsave(out_path, img)
【解决】
ds = pydicom.read_file(dcm_path)
img = ds.pixel_array # Extract image information
# Get the number of pixel
lens = img.shape[0] * img.shape[1]
# Get the max and min of pixel
temp = np.reshape(img, (lens,))
max_val = max(temp)
min_val = min(temp)
# Image normalization
img = (img - min_val) / (max_val - min_val)
# Draw the image and save
plt.imshow(img)
imageio.imsave(out_path, img)
版权声明:本文为CSDN博主「学习使人吃饱」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/da_VVi/article/details/119652791
暂无评论