ImageDataGenerator
. 目前,我正在使用
flow()
获取单个测试图像并保存增强图像的样本(最终我将使用
flow_from_directory()
).
问题是保存的图像总是饱和的,即图像中的大多数像素的值为(255、255、255)。尽管原始图像的最大值为~6000(65535)。我的期望是增强图像的最大值是~23。
下面是我使用的代码:
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