tensorflow图像预处理常用函数

1. 随机剪裁图像:
tf.random_crop(value(org. image), size=[row, column, channal],)


2. Randomly flip the image horizontally:
image = tf.image.random_flip_left_right(image)


3.随机HUE, max_delta必须介于0 和0.5之间:
tf.image.random_hue(image, max_delta=0.05)

随机对比度:
tf.image.random_contrast(image, lower=0.3, upper=1.0)

随机亮度:
tf.image.random_brightness(image, max_delta=0.2)

随机饱和度:
image = tf.image.random_saturation(image, lower=0.0, upper=2.0)


3.剪裁或填充,  如果图片过大, 则中心剪裁, 过小则填充, image可以是4维矩阵[batch, 高, 宽, channal], 或不带batch的三维:
tf.image.resize_image_with_crop_or_pad(image,target_height,target_width)


4. map功能, 一般 func.是一个lambda函数, elements为处理对象:
tf.map_fn(func., elements)

猜你喜欢

转载自blog.csdn.net/weixin_41947081/article/details/80944430