How to correctly calculate PSNR of yuv420p video?

12 views (last 30 days)
Hi, I am working on calculation of psnr for yuv420p formatted video. I found a sample code here: http://www.mathworks.com/matlabcentral/fileexchange/12455-psnr-of-yuv-videos . The code works fine for mse. However, I have one question on calculation of PSNR from MSE. If the MSE is calculated for individual component y, u or v which are individually 8 bits per sample, then the psnr is correctly calculated as 10*log10((2^8 - 1)/mse). But when taking whole 'yuv' for the mse, is it a total mse or average mse for y, u and v components? If we consider the downsampling of chroma components, say for yuv420p format, total or average bits per pixel will not be 8 (generally 12 or 16 bits total). Can anyone who has knowledge of this yuv format please clarify how to calculate psnr for yuv420p? Thanks in advance.
  4 Comments
Karbala'a Unvi. Science
Karbala'a Unvi. Science on 8 Aug 2020
Hi Dear Image Analyst
Is there any short way to calculate the PSNR and MSE for the video, than this one.
If you have an video to explain that I am so happy to see it
I am waitting for an answer from you.
Thank you in advance
Zee
Image Analyst
Image Analyst on 8 Aug 2020
There are now functions in the Image Processing Toolbox called immse() and psnr(). You could use those.

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 26 Mar 2016
When you pass in 'yuv', it does YUV1(:)-YUV2(:) so it does it element by element over every pixel in the image and averages them all together. It doesn't make a lot of sense since the scale and range of the Y axis is different than that of the U and V axes. You'd be better off calculating the CIE DeltaE 2000, which is more relevant to the way people see.
By the way, you don't need a File Exchange program since there is immse() and psnr() built in to the Image Processing Toolbox now.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!