I have a uint16 tiff image.
Keras is not correctly opening the image. All pixel values above 255 seem to be set to 255.
When the file is opened with Keras the returned object type is PIL.Image.Image, but when the file is opened with Pillow directly the returned object type is PIL.TiffImagePlugin.TiffImageFile. It's like the Keras version of Pillow is not using the tiff image plugin.
I'm using python 3.7.4 with the following packages:
- Keras 2.2.4
- keras pre-processing 2.2.4
- pillow 5.3.0
I've looked at the keras pre-processing load_img source code. The commands there don't seem to directly illustrate the issue, and I think it's because the tiff image plugin should have been recognized somewhere else but hasn't.
from keras.preprocessing.image import load_img
img = load_img('someuint16.tif', color_mode='grayscale')
print(type(img)) # prints PIL.Image.Image
from PIL import Image as pil_image
ex_pil_img = pil_image.open(path)
print(type(ex_pil_img)) # prints PIL.TiffImagePlugin.TiffImageFile