前言
最近用ssim测试图片画质损伤时,发现matlab自带ssim与之前一直使用的ssim计算得分有差异,故和同事开始确定差异所在。
不同的SSIM版本
这里提到不同的ssim版本主要基于matlab。如前言所述,主要分为2个实现。
版本1:Zhou Wang实现的版本(也是我之前一直用的版本),具体见:
滑铁卢大学:https://ece.uwaterloo.ca/~z70wang/research/ssim/
纽约大学:http://www.cns.nyu.edu/~lcv/ssim/版本2:matlab2015-ssim(matlab从2014开始加入了ssim)
2个版本的差异
虽然2个版本的代码实现完全不一样,但总的说,差异可以归结为以下几点:
1. downsample
Zhou Wang实现版本有downsample,他也推荐这么做,原因如下:
The precisely right scale depends on both the image resolution and the viewing distance and is usually difficult to be obtained. In practice, we suggest to use the following empirical formula to determine the scale for images viewed from a typical distance (say 3~5 times of the image height or width): 1) Let F = max(1, round(N/256)), where N is the number of pixels in image height (or width); 2) Average local F by F pixels and then downsample the image by a factor of F; and 3) apply the ssim_index.m pro