I exported the video acquired by Linac's EPID in dicom format. Try to analyze with pydicom as usual.
import pydicom
dicom_data = pydicom.dcmread(file_name)
Then
(0002, 0010) Transfer Syntax UID UI: MPEG2 Main Profile / Main Level
I see, it's a video. As usual
array = dicom_data.pixel_array
When I try to get a pixel array with
NotImplementedError: Unable to decode pixel data with a transfer syntax UID of '1.2.840.10008.1.2.4.100' (MPEG2 Main Profile / Main Level) as there are no pixel data handlers available that support it. Please see the pydicom documentation for information on supported transfer syntaxes
That doesn't work.
I was wondering if I could analyze it from dicom_data.PixelData
, but I was wondering if it could be analyzed as a normal video file.
import cv2
cap = cv2.VideoCapture(file_name)
That's not an error. Can you go?
frames = []
while True:
ret, frame = cap.read()
if ret == True:
frame=cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY) #I have a Gray scale
frames.append(frame)
else:
break
When I tried to do something, the list of frames
was successfully created.
If you call this np.array (frames) .shape
(143, 576, 720)
Well, you can see that it contains 143 images of 576 x 720.
After that, the first image could be displayed as plt.imshow (np.array (frames) [0 ,:,:])
.
It turned out that even if it is a dicom file, it can be analyzed using opencv as a normal video file.
Recommended Posts