Evaluate Video Quality

2023-11-04

How to evaluate video?
PSNR and SSIM.
PSNR is easy to calculate:

http://blog.csdn.net/c602273091/article/details/49861817

SSIM is more relevant to eye visibility.

How to calculate them?

Using Evalvid.

http://www2.tkn.tu-berlin.de/research/evalvid/
http://download.csdn.net/detail/leixiaohua1020/6374037

Run in cmd or using batching processing.

psnr.exe 1920 1080 420 src.yuv des.yuv > psnr.txt

MSU Video Quality Measurement Tool

http://www.compression.ru/video/quality_measure/video_measurement_tool_en.html

Source Code
From the code below, we can learn how to calculate ssim and psnr and some skills about VS.
Python Version will be displayed in next blog.

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

#ifdef _WIN32
  #include "stdint_w32.h"
  #define alloca _alloca
#else
  #include <stdint.h>
#endif

/****************************************************************************
 * structural similarity metric [from x264]
 ****************************************************************************/

#define x264_alloca(x) (void*)(((intptr_t)alloca((x)+15)+15)&~15)
#define XCHG(type,a,b) { type t = a; a = b; b = t; }
#define X264_MIN(a,b) ( (a)<(b) ? (a) : (b) )

static void ssim_4x4x2_core( const uint8_t *pix1, int stride1,
                             const uint8_t *pix2, int stride2,
                             int sums[2][4])
{
    int x, y, z;
    for(z=0; z<2; z++)
    {
        uint32_t s1=0, s2=0, ss=0, s12=0;
        for(y=0; y<4; y++)
            for(x=0; x<4; x++)
            {
                int a = pix1[x+y*stride1];
                int b = pix2[x+y*stride2];
                s1  += a;
                s2  += b;
                ss  += a*a;
                ss  += b*b;
                s12 += a*b;
            }
        sums[z][0] = s1;
        sums[z][1] = s2;
        sums[z][2] = ss;
        sums[z][3] = s12;
        pix1 += 4;
        pix2 += 4;
    }
}

static float ssim_end1( int s1, int s2, int ss, int s12 )
{
    static const int ssim_c1 = (int)(.01*.01*255*255*64 + .5);
    static const int ssim_c2 = (int)(.03*.03*255*255*64*63 + .5);
    int vars = ss*64 - s1*s1 - s2*s2;
    int covar = s12*64 - s1*s2;
    return (float)(2*s1*s2 + ssim_c1) * (float)(2*covar + ssim_c2)\
           / ((float)(s1*s1 + s2*s2 + ssim_c1) * (float)(vars + ssim_c2));
}

static float ssim_end4( int sum0[5][4], int sum1[5][4], int width )
{
    int i;
    float ssim = 0.0;
    for( i = 0; i < width; i++ )
        ssim += ssim_end1( sum0[i][0] + sum0[i+1][0] + sum1[i][0] + sum1[i+1][0],
                           sum0[i][1] + sum0[i+1][1] + sum1[i][1] + sum1[i+1][1],
                           sum0[i][2] + sum0[i+1][2] + sum1[i][2] + sum1[i+1][2],
                           sum0[i][3] + sum0[i+1][3] + sum1[i][3] + sum1[i+1][3] );
    return ssim;
}

float x264_pixel_ssim_wxh(uint8_t *pix1, int stride1, uint8_t *pix2, int stride2, int width, int height )
{
    int x, y, z;
    float ssim = 0.0;
    int (*sum0)[4] = x264_alloca(4 * (width/4+3) * sizeof(int));
    int (*sum1)[4] = x264_alloca(4 * (width/4+3) * sizeof(int));
    width >>= 2;
    height >>= 2;
    z = 0;
    for( y = 1; y < height; y++ )
    {
        for( ; z <= y; z++ )
        {
            XCHG( void*, sum0, sum1 );
            for( x = 0; x < width; x+=2 )
                ssim_4x4x2_core( &pix1[4*(x+z*stride1)], stride1, &pix2[4*(x+z*stride2)], stride2, &sum0[x] );
        }
        for( x = 0; x < width-1; x += 4 )
            ssim += ssim_end4( sum0+x, sum1+x, X264_MIN(4,width-x-1) );
    }
    return ssim / ((width-1) * (height-1));
}

int main(int n, char *cl[])
{
  FILE *f1, *f2;
  int ssim = 0, i, x, y, yuv, inc = 1, size = 0, N = 0, Y, F;
  double yrmse, diff, mean = 0, stdv = 0, *ypsnr = 0;
  unsigned char *b1, *b2;
  clock_t t = clock();

  if (n != 6 && n != 7) {
    puts("psnr x y <YUV format> <src.yuv> <dst.yuv> [multiplex] [ssim]");
    puts("  x\t\tframe width");
    puts("  y\t\tframe height");
    puts("  YUV format\t420, 422, etc.");
    puts("  src.yuv\tsource video");
    puts("  dst.yuv\tdistorted video");
    puts("  [multiplex]\toptional");
    puts("  [ssim]\toptional: calculate structural similarity instead of PSNR");
    return EXIT_FAILURE;
  }

  if ((f1 = fopen(cl[4], "rb")) == 0) goto A;
  if ((f2 = fopen(cl[5], "rb")) == 0) goto B;
  if (!(x = strtoul(cl[1], 0, 10)) ||
      !(y = strtoul(cl[2], 0, 10))) goto C; 
  if ((yuv = strtoul(cl[3], 0, 10)) > 444) goto D;
  if (cl[6] && !strcmp(cl[6], "multiplex")) inc = 2;
  if (cl[6] && !strcmp(cl[6], "ssim")) ssim = 1;

  Y = x * y;
  switch (yuv) {
    case 400: F = Y; break;
    case 422: F = Y * 2; break;
    case 444: F = Y * 3; break;
    default :
    case 420: F = Y * 3 / 2; break;
  }

  if (!(b1 = malloc(F))) goto E;
  if (!(b2 = malloc(F))) goto E;

  for (;;) {
    if (1 != fread(b1, F, 1, f1) || 1 != fread(b2, F, 1, f2)) break;

    if (++N > size) {
      size += 0xffff;
      if (!(ypsnr = realloc(ypsnr, size * sizeof *ypsnr))) goto E;
    }

    if (ssim) {
      mean += ypsnr[N - 1] = x264_pixel_ssim_wxh(b1, x, b2, x, x, y);
    } else {
      for (yrmse = 0, i = inc - 1; i < (inc == 1 ? Y : F); i += inc) {
        diff = b1[i] - b2[i];
        yrmse += diff * diff;
      }
      mean += ypsnr[N - 1] = yrmse ? 20 * (log10(255 / sqrt(yrmse / Y))) : 0;
    }

    printf("%.3f\n", ypsnr[N - 1]);
  }

  if (N) {
    mean /= N;

    for (stdv = 0, i = 0; i < N; i++) {
      diff = ypsnr[i] - mean;
      stdv += diff * diff;
    }
    stdv = sqrt(stdv / (N - 1));

    free(ypsnr);
  }

    fclose(f1);
    fclose(f2);

    fprintf(stderr, "%s:\t%d frames (CPU: %lu s) mean: %.2f stdv: %.2f\n",
    ssim ? "ssim" : "psnr", N, (unsigned long) ((clock() - t) / CLOCKS_PER_SEC), mean, stdv);

    return 0;

    A: fprintf(stderr, " Error opening source video file.\n"); goto X;
    B: fprintf(stderr, " Error opening decoded video file.\n"); goto X;
    C: fprintf(stderr, " Invalid width or height.\n"); goto X;
    D: fprintf(stderr, " Invalid YUV format.\n"); goto X;
    E: fprintf(stderr, " Not enough memory.\n");

    X: return EXIT_FAILURE;
}

Standard of Video Evaluation

http://download.csdn.net/detail/leixiaohua1020/6423425

Conclusion of Evaluation Method
PeakSignal to Noise Ratio(PSNR)
Ref to my ex-blog.
noise quality measure (NQM) index
Ref:N. Damera-Venkata, T.D. Kite, W.S. Geisler, B.L. Evans, and A.C.Bovik, “Image quality assessment based on a degradation model,” IEEE Trans. IP,vol. 9, pp. 636-650, 2000.
universal quality index (UQI)
Ref:Z. Wang and A.C. Bovik, “A universal image quality index,” IEEE SignalProcess. Lett., vol. 9, pp. 81-84, 2002.
structural similarity (SSIM) index
Ref:Z. Wang, A.C. Bovik, H.R. Sheikh, and E.P. Simoncelli,”Image qualityassessment: from error visibility to structural similarity,” IEEE Trans. IP,vol. 13, pp. 600-612, 2004.
multi-scaleSSIM (MS-SSIM) index
Ref:Z. Wang, E.P. Simoncelli, and A.C. Bovik, “Multi-scale structuralsimilarity for image quality assessment,” ACSSC’03, pp. 1398-1402, 2003.
information fidelity criterion (IFC) index
Ref:H.R. Sheikh, A.C. Bovik, and G. de Veciana, “An information fidelitycriterion for image quality assessment using natural scene statistics,” IEEETrans. IP, vol. 14, pp. 2117-2128, 2005.
visual information fidelity (VIF) index
Ref:H.R. Sheikh and A.C. Bovik, “Image information and visual quality,”IEEE Trans. IP, vol. 15, pp. 430-444, 2006.
visual signal to noise ratio (VSNR) index
Ref:D.M. Chandler and S.S. Hemami, “VSNR: a wavelet-based visualsignal-to-noise ratio for natural images,” IEEE Trans. IP, vol. 16, pp.2284-2298, 2007.
information content weighted SSIM (IW-SSIM) index
Ref:Z. Wang and Q. Li, “Information content weighting for perceptualimage quality assessment,” IEEE Trans. IP, vol. 20,
pp. 1185-1198, 2011.
Riesz transforms based feature similarity (RFSIM) index
Ref:L. Zhang, L. Zhang, and X. Mou, “RFSIM: a feature based imagequality assessment metric using Riesz transforms,” ICIP’10, pp. 321-324, 2010.
feature similarity (FSIM) index
Ref:L. Zhang, L. Zhang, X. Mou, and D. Zhang, “FSIM: a feature similarityindex for image quality assessment,” IEEE Trans. IP, vol. 20, pp. 2378-2386,2011.

All of the method above comes from ——
A COMPREHENSIVEEVALUATION OF FULL REFERENCE IMAGE QUALITY ASSESSMENT ALGORITHMS

http://blog.csdn.net/leixiaohua1020/article/details/38324973
http://blog.csdn.net/leixiaohua1020/article/details/12858773

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Evaluate Video Quality 的相关文章

  • C++ Template Class List

    转载请注明 http blog csdn net c602273091 article details 50717999 Introduction STL STL Standard Template Library 标准模板库 是惠普实验室
  • 写论文注意事项

    文献检索 搜索引擎的高级功能 搜索引擎主要www google com和scholar google com www baidu com则仅在检索中文时稍好点 英文很差 用处不大 我们常用的google侧重于网页的检索 Scholar则主要
  • Some Laws in IT

    Moore s Law 摩尔定律是由英特尔 Intel 创始人之一戈登 摩尔 Gordon Moore 提出来的 其内容为 当价格不变时 集成电路上可容纳的元器件的数目 约每隔18 24个月便会增加一倍 性能也将提升一倍 换言之 每一美元所
  • Jitter Removal in Image and Sequence

    去除重影 消抖 在 jitter removal images and video sequences Using robust decision Based Adaptive spatio temporal median Algorith
  • Conference and Journal Level in 2016

    中国计算机学会推荐国际学术会议和期刊目录 2015 年 中国计算机学会 中国计算机学会推荐国际学术期刊 计算机体系结构 并行与分布计算 存储系统 一 A 类 序号 刊物简称 刊物全称 出版社 网址 1 TOCS ACM Transactio
  • Video Evaluation by Python

    Here is the code to calculate for PSNR and SSIM of YUV My code has its advantage that it can process the problem by batc
  • Latex Skills

    ModernCV http 519488126 blog 163 com blog static 722401602014010555221 Paper 1 Blank 两个quad空格 a qquad b a qquad b 两个m的宽度
  • Evaluate Video Quality

    How to evaluate video PSNR and SSIM PSNR is easy to calculate http blog csdn net c602273091 article details 49861817 SSI
  • ML Introduction

    Task of ML Supervised Learning Classification and regression Unsepervised Learning Clustering Density Estimation Reducti
  • Visual Assist X AND MSDN

    assist X 推荐 这款插件是visual studio或者vc的插件 没想到vs用起来也可以这么爽 用起来居然比sourceinsight还好用 好用到哭 好用到哭 好用到哭 自动补全 补全的时候还可以看到对这个补全的东西的介绍 鼠标
  • SourceInght And Sublime Text 2 Using Skills

    工欲善其事 必先利其器 Sourceinsight 加入时间 http my oschina net xDreamYY blog 228814 Sourceinsight 加入快捷键 http www cnblogs com wangqig
  • 有实力的人才能谈梦想

    我总是徘徊 在犹豫 觉得自己做不到 只是在苟延残喘摆了 所谓的目标也不可能实现 今天我发现我做到了 原来也不是那么遥不可及 是自己不够自信 不够淡定 有实力的人聊梦想 没理想的人就想想怎么混工作吧 有实力的人 自信 坚定的毅力 不怕失败 淡
  • memset in C++ and C

    definition memset是计算机中C C 语言函数 将s所指向的某一块内存中的前n个 字节的内容全部设置为ch指定的ASCII值 第一个值为指定的内存地址 块的大小由第三个参数指定 这个函数通常为新申请的内存做初始化工作 其返回值
  • IMAGE REGISTRATION

    Classification Nature area based and feature based Different viewpoints multiview analysis image from different viewpoin
  • Latex Picture And Table Setting

    Four Picture in one column begin figure htb begin minipage b 48 linewidth centering centerline includegraphics width 4 0
  • Python Using EXE

    OS This method has its disadvantage if we want to stop this process We need do it by ourselves except seize the terminal
  • File Processing by Python

    Go through all the file in destination path import os import sys def GetFileList dir fileList newDir dir if os path isfi
  • ML Impossible and Rescure

    No Rule to Define will cause conflict Using available data to estimate target function if without rule target is unknown
  • Binary Classification Core PLA

    Target Step Verify My verification Pocket Algorithm Pros Cons of PLA
  • Process in Shell

    PID current process Get Process Get Process Select Object Name Get Process processname jm Select Object Get Process proc

随机推荐

  • Windbg分析高内存占用问题

    打Dump 远程客户应用服务器 32G内存占用已经消耗了78 而现场已经反馈收银系统接近奔溃了 要求先强制回收内存 反正也要奔溃了 先打Dump再说吧 PS 打Dump会挂起进程 导致应用无法响应 而打Dump的耗时 也是根据当时进程的内存
  • 循环打印数字文件名

    循环打印以顺序数字为标识 且格式为 0 的文件名 for s in range 10 a f train id s 03 tif print a train004 tif train005 tif train006 tif train007
  • 基于接口设计原则-java

    7种设计坏味道 1 僵化性 很难对系统进行改动 因为每个改动都会迫使许多对系统其他部分的其它改动 2 脆弱性 对系统的改动会导致系统中和改动的地方在概念上无关的许多地方出现问题 3 牢固性 很难解开系统的纠结 使之成为一些可在其他系统中重用
  • PyTorch中squeeze()和unsqueeze()函数理解

    squeeze arg 表示若第arg维的维度值为1 则去掉该维度 否则tensor不变 即若tensor shape arg 1 则去掉该维度 例如 一个维度为2x1x2x1x2的tensor 不用去想它长什么样儿 squeeze 0 就
  • 小程序:TypeError: Cannot read property ‘restore‘ of undefined

    去看了一些文字说肯能是data里面定义了 restore 而且还是引用类型 数据没有出来就渲染了也就导致了报错undefind 但是自己去看了一些data里面没有定义 restore 也是看了许久的文章才发现一篇文章说是 小程序的版本要降低
  • 笔试

    文章目录 前言 39 跨时钟域问题 1 从亚稳态入手 2 跨时钟域传输的几种情况 3 单bit信号的跨时钟域传输 3 1单bit信号从慢时钟域到快时钟域传输 3 2单bit信号从快时钟域到慢时钟域传输 脉冲同步器 窄脉冲捕捉电路 下期预告
  • 缓动 css,[CSS3] CSS缓动曲线整理

    常用效果 easeInSine cubic bezier 0 47 0 0 745 0 715 easeOutSine cubic bezier 0 39 0 575 0 565 1 easeInOutSine cubic bezier 0
  • SD卡SPI模式 读写block

    声明 第一次写教程 如若有错误 请指出更正 看了很多网上的教程 还是觉得很多教程中 写多个块的时候有些问题 因此经过3天的奋斗 写出自己的教程 本教程中 没有挂载文件系统 单纯读写Block 会破坏分区和数据 下节再 装上文件系统Fatfs
  • Html5监听返回事件

    常使用的场景 移动前端 1 安卓手机物理返回键 2 苹果手机在企业微信打开浏览器的返回按钮 移动前端开发语言是 vue 路由跳转 vue router hash模式 先介绍一下html5中history有哪些属性和API 我们用到了其中2个
  • Pcl粗配准矩阵不唯一

    经过一段时间的调试 发现转换矩阵不唯一 因此要将两个点云的数值减去一个值 使之最小 受到矩阵相乘相加受到的影响最小
  • 继承:父类和子类的关系

    继承 父类和子类的关系 一 父类引用指向子类对象时 1 若子类覆盖了某方法 则父类引用调用子类重新定义的新方法 2 若子类未覆盖某方法 则父类引用调用父类本身的旧方法 3 若子类覆盖了某属性 但父类引用仍调用父类本身的旧属性 4 若子类未覆
  • Linux命令后台运行

    Linux后台运行命令有两种方式 cmd 后台运行 关掉终端会停止运行 nohup cmd 后台运行 关掉终端不会停止运行 方式一 cmd cmd 实现让命令在后台运行 但不要将有用户交互的命令放到后台 这样命令会在后台等待用户输入 后台运
  • [leetcode160]

    Definition for singly linked list class ListNode object def init self x self val x self next None class Solution object
  • 用ChatGPT后被海外名校录取,泰库啦!!

    世界之大无奇不有 有人竟然因为使用ChatGPT后被海外大学录取 ChatGPT真的那么强大吗 竟然有这样子的能力 国内一些朋友因为各种问题没有办法使用ChatGPT 文章后面会给大家分享国内ChatGPT免注册免费使用的方法教程 今天一看
  • web安全的常用靶场

    文章目录 1 sqlmap 2 Test Lab 方便测试 列出以下WEB的靶场 仅供参考 1 sqlmap 0 作者出的漏洞测试环境 sqlmap 1 owasp 2 owaspbwa 3 xvwa 4 webgoad 5 DVWA 6
  • ananconda添加镜像

    先执行 conda config set show channel urls yes 生成该文件之后再修改 在用户目录下的 修改 condarc 文件 channels defaults show channel urls true cha
  • 联想小新air14安装ubuntu16.04

    首先正常安装 会遇到显卡问题 进入ubuntu高级模式 recovery mode resume 然后按照这篇教程整 https blog csdn net Guangli R article details 86636923 utm so
  • PCB设计 接地 铺铜的技巧

    PCB设计 接地 铺铜的技巧 1 PCB设计接地敷铜的技巧 pcb 电工之家 2 覆铜步骤及设计规则 百度文库 3 产品可靠性1 多层电路板应不应该在顶层和底层铺铜 Steven Aileen的博客 CSDN博客 4层板顶底层还用铺铜吗
  • 淘宝、支付宝菜鸟小程序取件码找不到的解决方法

    淘宝 支付宝菜鸟小程序身份码找不到的解决方法 今天拿快递的时候在淘宝里面找身份码 死活找不到 明明之前可以找到的 最后还是下载了菜鸟裹裹app才能取件 上网搜索了一下 发现有的地方很早就把小程序里面的身份码给阉割了 强行让用户下载app实属
  • Evaluate Video Quality

    How to evaluate video PSNR and SSIM PSNR is easy to calculate http blog csdn net c602273091 article details 49861817 SSI