1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PSNR, Mean Squared Error (MSE) 変換

Last updated at Posted at 2020-05-04

二つの画像がどれだけ違うかを表す指標としてはPSNRやMSEやSSIMが用いられます。このうちPSNRとMSEは本質的には同じものです。

この二つの間で頻繁に変換を行うことがあり、よく式を忘れてめんどくいので、一行ですが関数化して残しておくことにしました。

誰かのささやかな助けになるといいです。

psnr_mse_conversion.py
import math
def mse2psnr(mse, max_val=1):
    # max_val: 1 or 255
    return 10 * (math.log10(max_val**2 / mse))

def psnr2mse(psnr, max_val=1):
    return 1 / (10 ** (psnr / 10))

psnr2mse(30)
# 0.001
mse2psnr(0.001)
# 30.0

参考

wikipedia PSNR

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?