您的位置:首页 > 其它

Tensorflow-图像预处理

2017-10-30 17:00 127 查看
参考:https://github.com/tensorflow/models/blob/master/tutorials/image/cifar10/cifar10_input.py

def Image_processing(reshaped_image,height, width):
'''
图像预处理
参考:https://github.com/tensorflow/models/blob/master/tutorials/image/cifar10/cifar10_input.py
:return:
'''
# Image processing for training the network. Note the many random
# distortions applied to the image.

# Randomly crop a [height, width] section of the image.
distorted_image = tf.random_crop(reshaped_image, [height, width, 3])

# Randomly flip the image horizontally.
distorted_image = tf.image.random_flip_left_right(distorted_image)

# Because these operations are not commutative, consider randomizing
# the order their operation.
# NOTE: since per_image_standardization zeros the mean and makes
# the stddev unit, this likely has no effect see tensorflow#1458.
distorted_image = tf.image.random_brightness(distorted_image,
max_delta=63)
distorted_image = tf.image.random_contrast(distorted_image,
lower=0.2, upper=1.8)

# Subtract off the mean and divide by the variance of the pixels.
float_image = tf.image.per_image_standardization(distorted_image)

# Set the shapes of tensors.
return float_image.set_shape([height, width, 3])
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: