I am working on Dicom images using pydicom. But my project is in fasai
and I want to open that Dicom image using the fastai library. In fastai
, we normally do open_image(path) its work fine for png
or jpg
but if we have Dicom images we have no method to open it easily. so I use pydicom and them get their pixel array and then convert to RGB and resized. But when I again apply to open that NumPy array which I made it can't open it because open_image needs
path` not a numpy image. I have a question that how I can open a Dicom image like we open a simple png image.
we open normal images like in fastai:
im = open_image(img_path)
img.show(figsize=(4,4), ax=axs[0])
it gives us shape of (3,H,W)
but in Dicom’s image, it’s not easy to open it as same. I need to open it like before. I tried the below code to get the image using the pydicom library.
if (extension == 'dicom'):
xray = read_xray(img_path)
img = resize(xray)
img = to_rgb(img)
img = normalize(img)
img = torch.from_numpy(img)
img = np.transpose(img, [2, 0, 1])
Please help to get of from this probelm.