阅读(13k) 书签 (0)

TensorFlow函数:tf.image.psnr

2018-06-07 10:54 更新

tf.image.psnr函数

tf.image.psnr(
    a,
    b,
    max_val,
    name=None
)

定义在:tensorflow/python/ops/image_ops_impl.py.

返回a和b之间的峰值信噪比.

这旨在用于信号(或图像).在批处理中为每个图像生成一个信噪比(PSNR)值.

输入的最后三个维度预计为[height, width, depth].

示例:

# Read images from file.
im1 = tf.decode_png('path/to/im1.png')
im2 = tf.decode_png('path/to/im2.png')
# Compute PSNR over tf.uint8 Tensors.
psnr1 = tf.image.psnr(im1, im2, max_val=255)

# Compute PSNR over tf.float32 Tensors.
im1 = tf.image.convert_image_dtype(im1, tf.float32)
im2 = tf.image.convert_image_dtype(im2, tf.float32)
psnr2 = tf.image.psnr(im1, im2, max_val=1.0)
# psnr1 and psnr2 both have type tf.float32 and are almost equal.

参数:

  • a:第一组图像.
  • b:第二组图像.
  • max_val:图像的动态范围(即最大允许值和最小允许值之间的差值).
  • name:用于嵌入计算的命名空间.

返回:

a和b之间的标量PSNR,返回的张量具有tf.float32类型和形状[batch_size,1].