Created
January 21, 2021 13:05
-
-
Save paladin3895/519e0ee1b17f3317f1e15f27a26bc264 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import cv2 | |
| import os | |
| import pydicom | |
| inputdir = './train/' | |
| outdir = './png/' | |
| #os.mkdir(outdir) | |
| test_list = [ f for f in os.listdir(inputdir)] | |
| for f in test_list[:10]: # 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('.dicom','.png'),img) # write png image |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.