# Which PSNR formula is used in Tensorflow?

I would like to know which formula of PSNR is used in tf.image.psnr( a, b, max_val, name=None )

I found these PSNR formulae

PSNR(f,g)=10 log_10⁡(〖255〗^2/MSE(f,g) )

PSNR(f,g)=10 log_10⁡(〖MAX〗^2/MSE)

but I do not understand which kind of formula is used in tf.image.psnr function. Thanks in advance if you could explain me.

tensorflow

According to the function signature, you have to specify the `max_val`.

The formulas you’ve shown are identical if `max_val` = 255, which is usually the maximum possible value per pixel per channel.

Sometimes you know that the image has been converted and the values lie in range 0 to 1. In such case, you specify `max_val` to be 1.

According to sources, the formula is a bit different:

So:
(20 * log(max_val) / log(10)) - ((10 / log(10)) * log(mse))

1 Like

Your explanation saves me! Thank you so much.