0

On Windows 10, I have installed ImageMagick, Version 7.1.1-Q16-HDRI.

I have a high resolution .png image that I convert to jpg with 75% quality:

magick myImage.png -quality 75 myImage.jpeg

Now I want to calculate SSIM to judge the quality of the .jpeg in comparison to the original .png.

First, I am using ffmpeg.exe version 4.2.3 from the very same ImageMagick installation:

ffmpeg.exe -i myImage.jpeg -i myImage.png -lavfi ssim=stats_file=ssim_logfile.txt -f null -

Results in ssim_logfile.txt:

n:1 Y:0.959684 U:0.957603 V:0.976335 All:0.962112 (14.215018)

So I assume that the SSIM value has been calculated as 0.962112

Now I'll use magick to calculate the same metric:

magick myImage.jpeg myImage.png -metric SSIM -compare -format "%[distortion]" info:

Output is:

0.925167

That's a huge difference! So I think I'm making an error here with one or the other way.

What is the correct way to calculate SSIM?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
jamacoe
  • 519
  • 4
  • 16
  • PNGs store color values as RGB, JPEGs as YUV. There are various transform matrices that can be used for conversion, depending on signal source. So my first guess is IM and FFmpeg have used different matrices. – Gyan Mar 22 '23 at 10:57
  • 1
    There is no "best or proper" way. SSIM is a technique which depends upon the kernels used (radius and sigma for blur) – fmw42 Mar 22 '23 at 15:14

0 Answers0