简体   繁体   English

WebP的SSIM计算

[英]SSIM calculation for WebP

ImageMagick's 'compare' seems to provide irrelevant numbers when using SSIM as the comparison metric. 当使用SSIM作为比较指标时,ImageMagick的“比较”似乎提供了不相关的数字。 I'm using ImageMagick 7.0.8-58 Q16. 我正在使用ImageMagick 7.0.8-58 Q16。

I tried it with various levels of WebP compression (including lossless) 我尝试了各种级别的WebP压缩(包括无损压缩)

magick compare -metric SSIM original.png lossless.webp difference.png

provides 0.734809. 提供0.734809。 While I would expect something around 0.999 for a visually indistinguishable image (apparently no artifacts, because it's a WebP file compressed in lossless mode) 虽然我希望视觉上无法分辨的图像大约在0.999左右(显然没有伪像,因为它是在无损模式下压缩的WebP文件)

Receiving such results, I assumed that there is a problem with comparing PNG to WebP specifically, so I tried to compare original PNG to compressed JPEG with a target SSIM. 收到这样的结果后,我假设专门将PNG与WebP进行比较存在问题,因此我尝试将原始PNG与具有目标SSIM的压缩JPEG进行比较。 SSIM package from Fred's ImageMagick Scripts gave results of ssim=0.949 and dssim=0.051. Fred的ImageMagick Scripts的SSIM软件包给出的结果为ssim = 0.949和dssim = 0.051。 ImageMagick on contrary gave 0.711049 result for the very same file. 相反,ImageMagick对于同一文件给出了0.711049的结果。

magick compare -metric SSIM original.png compressed.jpg difference.png

Sadly, Fred's SSIM doesn't seem to work with WebP and GraphicsMagick's compare doesn't support SSIM. 可悲的是,Fred的SSIM似乎无法与WebP一起使用,而GraphicsMagick的比较不支持SSIM。 So how do I get an accurate SSIM from ImageMagick or what are the other ways to get SSIM for WebP files? 那么,如何从ImageMagick获取准确的SSIM或通过WebP文件获取SSIM的其他方法是什么?

Do you have webp installed as a delegate to ImageMagick? 您是否已将Webp安装为ImageMagick的委托? If so, it should show in the delegates list from magick -version . 如果是这样,它应该显示在magick -version的代表列表中。 What is your platform/OS? 您的平台/操作系统是什么?

My ssim script seems to work for me on IM 7.0.8.59 Q16 Mac OSX 我的sim脚本似乎在IM 7.0.8.59 Q16 Mac OSX上对我有用

magick rose: rose.webp
ssim rose.webp rose.webp

ssim=1 dssim=0


Also ImageMagick compare works fine for me also. ImageMagick比较也对我很好。

magick compare -metric ssim rose.webp rose.webp null:

1


I believe that lower values for webp to png may have to do with the webp lossy compression. 我认为webp到png的较低值可能与webp有损压缩有关。 I get similar values from ImageMagick and from my script: 我从ImageMagick和脚本中获得了相似的值:

magick rose: rose.webp
magick rose: rose.png

magick compare -metric ssim rose.webp rose.png null:
0.895189

ssim rose.webp rose.png
ssim=0.895 dssim=0.105


However, if I use lossless compression, then I get a perfect comparision: 但是,如果我使用无损压缩,则可以得到完美的比较:

magick rose: -define webp:lossless=true rose.webp
magick rose: rose.png

ssim rose.webp rose.png
ssim=1 dssim=0

magick compare -metric ssim rose.webp rose.png null:
1

ADDITION: 加成:

For me, it does not matter which order the webp image is in the command line. 对我来说,webp图像在命令行中的顺序无关紧要。

Here, I use lossless compression. 在这里,我使用无损压缩。

magick rose: rose.png
magick rose: -define webp:lossless=true rose.webp

magick compare -metric ssim rose.webp rose.png null:
1
1magick compare -metric ssim rose.png rose.webp null:
1

Here, I do not use lossless compression. 在这里,我不使用无损压缩。

magick rose: rose.png
magick rose: rose.webp

magick compare -metric ssim rose.webp rose.png null:
0.895189
magick compare -metric ssim rose.png rose.webp null:
0.895189

Actually the answer is pretty simple. 其实答案很简单。 I used a bugged version of ImageMagick. 我使用了错误版本的ImageMagick。 Just changing the order of comparison did the trick: 只需更改比较顺序即可达到目的:

magick compare -metric SSIM compressed.jpg original.png difference.png

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM