使用tensorflow
分别对数据集中图像使用翻转(垂直和左右)和旋转(90度的倍数)
import tensorflow as tf
import os
def trans(img, img_data, sav):
#翻转操作是镜像的,旋转是非镜像的
#垂直翻转
flipped_up_down = tf.image.flip_up_down(img_data)
#水平翻转
flipped_left_right = tf.image.flip_left_right(img_data)
#以90度的倍数进行旋转
rotate_90 = tf.image.rot90(img_data, k=1)
rotate_180 = tf.image.rot90(img_data, k=2)
rotate_270 = tf.image.rot90(img_data, k=3)
#编码
encoded_image_u = tf.image.encode_jpeg(flipped_up_down)
encoded_image_l = tf.image.encode_jpeg(flipped_left_right)
encoded_image_r9 = tf.image.encode_jpeg(rotate_90)
encoded_image_r18 = tf.image.encode_jpeg(rotate_180)
encoded_image_r27 = tf.image.encode_jpeg(rotate_270)
with tf.Session() as sess:
u, l, r9, r18, r27 = sess.run([encoded_image_u, encoded_image_l, encoded_image_r9,
encoded_ima