I am trying to read an image using PIL (I think it needs to be PIL because I am working with a filehandle and OpenCV was throwing an error when I tried using it to read in the image).
I would like to read in the image like so;
pil_image = Image.open('sample_image.tif').convert('RGB') # it is in tiff format
# and convert to numpy array
img = np.asarray(pil_image)
plt.imshow(img)
However, whenever I try to convert the image and plot it, I get a blank result (as shown above). I need the NumPy array to be a uint8 for preprocessing reasons. But every method I use to convert the original image from PIL to a NumPy array with dtype=uint8 (the other method I tried is this..
pil_image = Image.open('Sample_image.tif')
img = np.array(pil_image) / 255
img = img.astype(np.uint8)
), I either get a blank screen or undesired results. Finally, I tried following some suggestions from here Convert image from PIL to openCV format, and I get no luck. Any suggestions on how to solve this would be really helpful cheers.