images.py 文件源码

python
阅读 34 收藏 0 点赞 0 评论 0

项目:dynamic-training-bench 作者: galeone 项目源码 文件源码
def rgb2yuv(rgb):
    """
    Convert RGB image into YUV https://en.wikipedia.org/wiki/YUV
    """
    rgb2yuv_filter = tf.constant([[[[0.299, -0.169,
                                     0.499], [0.587, -0.331, -0.418],
                                    [0.114, 0.499, -0.0813]]]])
    rgb2yuv_bias = tf.constant([0., 0.5, 0.5])

    rgb = tf.expand_dims(rgb, 0)

    temp = tf.nn.conv2d(rgb, rgb2yuv_filter, [1, 1, 1, 1], 'SAME')
    temp = tf.nn.bias_add(temp, rgb2yuv_bias)
    temp = tf.squeeze(temp, [0])

    return temp


# Adapted from
# https://github.com/pavelgonchar/colornet/blob/master/train.py
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号