How to Convert DICOM images into other formats (.png, .jpeg etc.) in Python

In the medical imaging domain, DICOM is a standard format for storing images. If you want to convert these type of dicom images into .png or other extensions. Then below code will be helpful for you.



import mritopng
import os
PATH = os.getcwd()
data_path = PATH + '\Calc_num'
data_dir_list = os.listdir(data_path)
for input_path in data_dir_list:
    path=input_path.replace("dcm","png")
    mritopng.convert_file("Calc_num\\"+input_path, "Calc_num_png\\" +path)

Comments