前言

最近用ssim測試圖片畫質(zhì)損傷時,發(fā)現(xiàn)matlab自帶ssim與之前一直使用的ssim計算得分有差異,故和同事開始確定差異所在。

不同的SSIM版本

這里提到不同的ssim版本主要基于matlab。如前言所述,主要分為2個實現(xiàn)。

2個版本的差異

雖然2個版本的代碼實現(xiàn)完全不一樣,但總的說,差異可以歸結(jié)為以下幾點:

1. downsample

  • Zhou Wang實現(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