Reputation: 376
I read a .dcm image from my own dataset using tfio.image.decode_dicom_image following this link. The shape of the read image is shown as (None,None,None,None). While displaying the image using plt.imshow, the output of np.squeeze is zero-dimensional and hence giving error in 2-d image display. Could someone please help me understand what is the problem?
Upvotes: 0
Views: 198
Reputation: 467
I think what you've missed is reading the file first. I was also thinking that tfio.image.decode_dicom_image
will eliminate the need for the tf.io.read_file
, but no.
import tensorflow_io as tfio
image_bytes = tf.io.read_file('dicom_00000001_000.dcm')
image = tfio.image.decode_dicom_image(image_bytes, dtype=tf.uint16)
Reference : https://www.tensorflow.org/io/tutorials/dicom?hl=tr
Upvotes: 0
Reputation: 510
Try pydicom to read .dcm data
from pydicom import dcmread
import matplotlib.pyplot as plt
read= dcmread('000000.dcm')
img=read.pixel_array
plt.imshow(img,cmap = 'gray')
or sometime the directiory is wrong
Upvotes: 0