基于Tensorflow深度学习框架下的图像增强(二)

本文探讨了使用ImageDataGenerator进行图像预处理时,'wrap'和'nearest'两种填充模式的实践。首先通过实例展示了如何使用这两个模式生成并保存数据,然后比较了它们在保持图像完整性上的差异。
摘要由CSDN通过智能技术生成
datagen = image.ImageDataGenerator(fill_mode='wrap',zoom_range=[4,4])
gen = image.ImageDataGenerator()
data = gen.flow_from_directory(in_path,batch_size=1,class_mode=None,shuffle = True, target_size = (224,224))
np_data = np.concatenate([data.next() for i in range(data.n)])
datagen.fit(np_data)
gen_data = datagen.flow_from_directory(in_path,batch_size = 1, shuffle = False, 
                                       save_to_dir = out_path+'fill_mode',
                                       save_prefix='gen',target_size=(224,224))
for i in range(3):
    gen_data.next()
print_result(out_path+'fill_mode/*')

datagen = image.ImageDataGenerator(fill_mode='nearest',zoom_range=[4,4])
gen = image.ImageDataGenerator()
data = gen.flow_from_directory(in_path,batch_size=1,class_mode=None,shuffle = True, target_size = (224,224))
np_data = np.concatenate([data.next() for i in range(data.n)])
datagen.fit(np_data)
gen_data = datagen.flow_from_directory(in_path,batch_size = 1, shuffle = False, 
                                       save_to_dir = out_path+'nearest',
                                       save_prefix='gen',target_size=(224,224))
for i in range(3):
    gen_data.next()
print_result(out_path+'nearest/*')

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值