I have 16-bit images (grayscale if that's relevant) that I'm trying to augment using Keras' ImageDataGenerator. For now, I'm using flow() to take a single test image and save out samples of the augmented images (ultimately I'll use flow_from_directory()).
The problem is that the images that get saved are always saturated, i.e. most pixels in the image have a value of (255, 255, 255). This is despite the original image having a max value of ~6000 out of 65535. My expectation would be for the max value of the augmented images to be ~23.
I definitely don't want to be feeding my model saturated images, since that means a lot of the dynamic range is lost. Any ideas what's going on here?
Here's the code I'm using:
from keras.preprocessing.image import ImageDataGenerator, img_to_array, load_img
test_img = img_to_array(load_img('image10.tif'))
test_img = test_img.reshape((1,) + test_img.shape)
train_datagen = ImageDataGenerator(
rotation_range = 90,
horizontal_flip = True,
vertical_flip = True,
fill_mode = 'constant',
rescale = 1./65535)
i = 0
for batch in train_datagen.flow(test_img_array, batch_size=1, save_to_dir=preview_output, save_prefix='test_img', save_format='tif'):
i += 1
if i > 10:
break