#tf.image.rot90()与tf.image.flip_up_down()增加原始数据到8倍

#python 3.6
import matplotlib.pyplot as plt
import tensorflow as tf
image_raw_data = tf.io.gfile.GFile(r'./data/IMG/TaylorSwift.jpg','rb').read()
with tf.compat.v1.Session() as sess:
img_data = tf.image.decode_jpeg(image_raw_data)
#img_data = tf.image.decode_png(image_raw_data)
print(img_data.eval())
plt.subplot(2,4,1)
plt.imshow(img_data.eval())
plt.axis('off')
rotate_r90 = tf.image.rot90(img_data ,k=1)
plt.subplot(2,4,2)
plt.imshow(rotate_r90.eval())
plt.axis('off')
rotate_r180 = tf.image.rot90(img_data ,k=2)
plt.subplot(2,4,3)
plt.imshow(rotate_r180.eval())
plt.axis('o
TensorFlow图像增强:翻转与旋转

本文介绍如何使用TensorFlow的tf.image.rot90()和tf.image.flip_up_down()函数来实现图像的90度旋转和上下翻转,从而实现原始数据的8倍扩充。内容针对Python 3.6环境。
最低0.47元/天 解锁文章
996

被折叠的 条评论
为什么被折叠?



