我有一个dicom图像的文件夹,我把这些图像存储在一个数组中,我想把它们打印到另一个文件夹中。在
我找不到像cv2.imwrite这样写出每个图像的方法
import pydicom
import skimage, os
import numpy as np
FolderPathName = r'FolderPathName'
slices = [pydicom.read_file(FolderPathName + imagename) for imagename in os.listdir(FolderPathName)]
# Sort the dicom slices in their respective order
slices.sort(key=lambda x: int(x.InstanceNumber))
for x in range(len(slices)):
#write the images in a new folder
方法1: 就你而言, 答案是。。。在
方法2: 但是,有更好的方法来处理dicom文件。。。在
^{pr2}$在上述代码中, 步骤1的重点是文件路径处理。将代码轻松地移植到不同的环境中对您是有好处的。在
步骤2是主要的代码,主要用于任何类型的图像处理。在
相关问题 更多 >
编程相关推荐