-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdcmtest.py
46 lines (34 loc) · 894 Bytes
/
dcmtest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from nilearn import image
import nilearn
import numpy as np
import cv2
from pydicom import dcmread
# import mayavi
from nilearn import plotting
from mayavi import mlab
import cv2
import os
import glob
import pydicom
##########
input_dir=r'/home/oem/Desktop/Project/DICOM/DCM/Shoulder'
data_path = os.path.join(input_dir, '*dcm')
files = glob.glob(data_path)
data=[]
def dcm2bndry(files):
for f1 in sorted(files):
RefDs=pydicom.dcmread(f1)
print(RefDs)
pxl=RefDs.pixel_array
data.append(pxl)
# cv2.namedWindow('image',cv2.WINDOW_GUI_NORMAL)
# cv2.imshow('image',pxl)
# cv2.waitKey(1)
return data
s=dcm2bndry(files)
print(np.shape(s))
ss=np.array(s)
# mlab.pipeline.volume(mlab.pipeline.scalar_field(ss))
mlab.contour3d(ss)
# s = mlab.mesh(ss)
mlab.show()