I am trying to resize DICOM images of different dimensions into a common dimension size for training my neural network. I thought that cv2 could solve my problem. But I am getting a 'datatype not understood error' in my jupyter notebook
I am trying to create a tensorflow neural network that could predict the class of the image. Thus, I need images of a common dimension size for the first layer training
Here is the function I have created:
IMG_PX_SIZE = 224
def resize(img_dcm):
return cv2.resize(np.array(img_dcm.pixel_array, (IMG_PX_SIZE,IMG_PX_SIZE)))
This is how I read the dcm files and pass it to the function:
img = pydi.dcmread(PATH)
image = resize(img)
I expected it to output a 224*224 sized image. But I am getting the following error:
<ipython-input-66-3cf283042491> in resize(img_dcm)
1 IMG_PX_SIZE = 224
2 def resize(img_dcm):
----> 3 return cv2.resize(np.array(image.pixel_array, (IMG_PX_SIZE,IMG_PX_SIZE)))
TypeError: data type not understood