I created a uncompressed dicom video from an ultrasound device. Now I want to read it frame by frame in a python application and for now save the file. Later I want to add some image processing. So far I've tried to extract the bytes belonging to the first frame.
import dicom
import array
from PIL import Image
filename = 'image.dcm'
img = dicom.read_file(filename)
byte_array = array.array('B', img.PixelData[0:(img.Rows * img.Columns)])
How do I get now this bytearray into a file (bitmap, jpeg whatever)? I've tried using the python image library with image = Image.fromarray(byte_array)
but got an error.
AttributeError: 'str' object has no attribute 'array_interface'
I guess somewhere I also have to specify the dimensions of the image but haven't figured out how.