前言
最近用ssim測(cè)試圖片畫(huà)質(zhì)損傷時(shí),發(fā)現(xiàn)matlab自帶ssim與之前一直使用的ssim計(jì)算得分有差異,故和同事開(kāi)始確定差異所在。
不同的SSIM版本
這里提到不同的ssim版本主要基于matlab。如前言所述,主要分為2個(gè)實(shí)現(xiàn)。
版本1:Zhou Wang實(shí)現(xiàn)的版本(也是我之前一直用的版本),具體見(jiàn):
滑鐵盧大學(xué):https://ece.uwaterloo.ca/~z70wang/research/ssim/
紐約大學(xué):http://www.cns.nyu.edu/~lcv/ssim/版本2:matlab2015-ssim(matlab從2014開(kāi)始加入了ssim)
2個(gè)版本的差異
雖然2個(gè)版本的代碼實(shí)現(xiàn)完全不一樣,但總的說(shuō),差異可以歸結(jié)為以下幾點(diǎn):
1. downsample
Zhou Wang實(shí)現(xiàn)版本有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