Page 1 of 1

possible bug -metric fuzz using convert IM 6.9.8.0 Q16 Mac OSX

Posted: 2017-03-14T21:00:14-07:00
by fmw42
See first pair of images at viewtopic.php?f=2&t=31535#p143599


Two issues:

1) compare and convert methods do not agree for metric fuzz or metric rmse, when there is transparency

2) for -metric rmse, results are not the same with and without transparency


-metric fuzz is supposed to take transparency into account. I am not sure what that means. Nevertheless I get different results from:

Code: Select all

convert ed3k2rBk7HZzJccH98x9.png qTCKVKFPImX2BcpnSV3d.png +repage -resize 256x256^! miff:- |\
compare -metric fuzz - null:
21586.8 (0.329394)

Code: Select all

convert ed3k2rBk7HZzJccH98x9.png qTCKVKFPImX2BcpnSV3d.png +repage -resize 256x256^! -metric fuzz -format %[distortion] -compare info:
0.182687

Is this a bug with the latter or am I misunderstanding the difference between the two methods and/or what -metric fuzz is doing?

Does -metric fuzz compare all 4 channels RGBA separately and compute the 4 channel fuzz (rmse) value? Or is it blending with alpha?

What is -metric rmse supposed to do if alpha is present?


Note if I use metric rmse, then I still get different results

Code: Select all

convert ed3k2rBk7HZzJccHmX2BcpnSV3d.png +repage -resize 256x256^! miff:- |\
> compare -metric rmse - null:
18694.8 (0.285264)

Code: Select all

convert ed3k2rBk7HZzJccH98x9.png qTCKVKFPImX2BcpnSV3d.png +repage -resize 256x256^! -metric rmse -format %[distortion] -compare info:
0.182687

The latter using -metric rmse gives the same answer as the second -metric fuzz. So it seems that -metric fuzz is not taking into account the alpha channel, if it is supposed to and if -metric rmse is not supposed to.

If I turn alpha off on -metric rmse, then I get

Code: Select all

convert ed3k2rBk7HZzJccH98x9.png qTCKVKFPImX2BcpnSV3d.png +repage -alpha off -resize 256x256^! miff:- |\
compare -metric rmse - null:
49685.2 (0.758148)

Code: Select all

convert ed3k2rBk7HZzJccH98x9.png qTCKVKFPImX2BcpnSV3d.png +repage -alpha off -resize 256x256^! -metric rmse -format %[distortion] -compare info:
0.758141

These two values agree, but do not agree with when alpha is on. So what is the alpha channel doing with -metric rmse, if it is not supposed to take transparency into account?

Re: possible bug -metric fuzz using convert IM 6.9.8.0 Q16 Mac OSX

Posted: 2017-03-15T05:38:19-07:00
by magick
Download the latest beta release and add -channel rgba to your command line. Do you now get expected results?

Re: possible bug -metric fuzz using convert IM 6.9.8.0 Q16 Mac OSX

Posted: 2017-03-15T10:10:45-07:00
by fmw42
What is the expected behavior for -metric rmse and metric fuzz when alpha is available? That is how is alpha treated with or without -channel rgba for the two metrics?

Re: possible bug -metric fuzz using convert IM 6.9.8.0 Q16 Mac OSX

Posted: 2017-03-15T10:46:41-07:00
by magick
ImageMagick defaults in IMv6 to just the RGB channel so it should ignore the alpha channel unless you specifify -channel RGBA. However, make sure you have the latest 6.9.8-1 beta before you test.

Re: possible bug -metric fuzz using convert IM 6.9.8.0 Q16 Mac OSX

Posted: 2017-03-15T10:57:46-07:00
by fmw42
IM 6.9.8.1 Q16 beta Mac OSX

Without -channel rgba:

metric -fuzz shows different results for the two methods

Code: Select all

im6beta convert ed3k2rBk7HZzJccH98x9.png qTCKVKFPImX2BcpnSV3d.png +repage -resize 256x256^! miff:- | im6beta compare -metric fuzz - null:
18694.8 (0.285264)

Code: Select all

im6beta convert ed3k2rBk7HZzJccH98x9.png qTCKVKFPImX2BcpnSV3d.png +repage -resize 256x256^! -metric fuzz -format %[distortion] -compare info:
0.182687


metric -rmse shows different results for the two methods But each match -metric fuzz

Code: Select all

im6beta convert ed3k2rBk7HZzJccH98x9.png qTCKVKFPImX2BcpnSV3d.png +repage -resize 256x256^! miff:- | im6beta compare -metric rmse - null:
18694.8 (0.285264)

Code: Select all

im6beta convert ed3k2rBk7HZzJccH98x9.png qTCKVKFPImX2BcpnSV3d.png +repage -resize 256x256^! -metric rmse -format %[distortion] -compare info:
0.182687


With -channel rgba:

-metric fuzz now shows the same results for both methods

Code: Select all

im6beta convert ed3k2rBk7HZzJccH98x9.png qTCKVKFPImX2BcpnSV3d.png +repage -resize 256x256^! miff:- | im6beta compare -channel rgba -metric fuzz - null:
18694.8 (0.285264) same result as without -channel rgba

Code: Select all

im6beta convert ed3k2rBk7HZzJccH98x9.png qTCKVKFPImX2BcpnSV3d.png +repage -resize 256x256^! -channel rgba -metric fuzz -format %[distortion] -compare info:
0.285254


-metric rmse now shows the same results for both methods But the same as -metric fuzz

Code: Select all

im6beta convert ed3k2rBk7HZzJccH98x9.png qTCKVKFPImX2BcpnSV3d.png +repage -resize 256x256^! miff:- | im6beta compare -channel rgba -metric rmse - null:
18694.8 (0.285264)

Code: Select all

im6beta convert ed3k2rBk7HZzJccH98x9.png qTCKVKFPImX2BcpnSV3d.png +repage -resize 256x256^! -channel rgba -metric rmse -format %[distortion] -compare info:
0.285254

So there are still issues and questions:

1) Why is -metric rmse and -metric fuzz each giving different results from the two approaches when alpha is present but not using -channel rgba?

2) Why is -metric rmse and -metric fuzz not different when using -channel rgba. I though only -metric fuzz was alpha sensitive

3) Why isn't alpha just ignored for -metric fuzz and especially -metric rmse if not using -channel rgba. What does compare do in the presence of an alpha channel if -channel rgba is not enabled?

Re: possible bug -metric fuzz using convert IM 6.9.8.0 Q16 Mac OSX

Posted: 2017-03-15T14:33:59-07:00
by fmw42
I get quite a different result from either method if I disable alpha

Code: Select all

im6beta convert ed3k2rBk7HZzJccH98x9.png qTCKVKFPImX2BcpnSV3d.png +repage -alpha off -resize 256x256^! miff:- | im6beta compare -metric rmse - null:
49685.2 (0.758148)

Code: Select all

im6beta convert ed3k2rBk7HZzJccH98x9.png qTCKVKFPImX2BcpnSV3d.png +repage -alpha off -resize 256x256^! -metric rmse -format %[distortion] -compare info:
0.758148

Should this not agree with one of the two approaches when not using -channel rgba?

Re: possible bug -metric fuzz using convert IM 6.9.8.0 Q16 Mac OSX

Posted: 2017-03-15T16:44:57-07:00
by fmw42
Results in IM 6.9.8.1 beta and IM 7.0.5-3 beta are now consistent. But note that IM 6 has -channel rgb as the default for compare and IM 7 has -channel rgba for the default in compare. -metric fuzz and -metric rmse are the same for -fuzz 0 in -metric fuzz. When using -channel rgba, the compare will use 4 channels. When using -channel rgb, the compare will use only 3 channels. When using -channel rgba and -alpha off, the alpha will be set to fully opaque and the compare will use 4 channels. Now both compare and convert -compare give the same results.

rmse; default

Code: Select all

im7beta magick ed3k2rBk7HZzJccH98x9.png qTCKVKFPImX2BcpnSV3d.png +repage -resize 256x256^! miff:- | im7beta magick compare -metric rmse - null:
18727.4 (0.285761)  <--- note uses -channel rgba as default

im6beta convert ed3k2rBk7HZzJccH98x9.png qTCKVKFPImX2BcpnSV3d.png +repage -resize 256x256^! miff:- | im6beta compare -metric rmse - null:
11972.9 (0.182694)  <--- note uses -channel rgb as default

im7beta magick ed3k2rBk7HZzJccH98x9.png qTCKVKFPImX2BcpnSV3d.png +repage -resize 256x256^! -metric rmse -format %[distortion] -compare info:
0.285874  <--- note uses -channel rgba as default

im6beta convert ed3k2rBk7HZzJccH98x9.png qTCKVKFPImX2BcpnSV3d.png +repage -resize 256x256^! -metric rmse -format %[distortion] -compare info:
0.182687  <--- note uses -channel rgb as default

# rmse; alpha off

Code: Select all

im7beta magick ed3k2rBk7HZzJccH98x9.png qTCKVKFPImX2BcpnSV3d.png +repage -alpha off -resize 256x256^! miff:- | im7beta magick compare -metric rmse - null:
49691.4 (0.758242)

im6beta convert ed3k2rBk7HZzJccH98x9.png qTCKVKFPImX2BcpnSV3d.png +repage -alpha off -resize 256x256^! miff:- | im6beta compare -metric rmse - null:
49685.2 (0.758148)

im7beta magick ed3k2rBk7HZzJccH98x9.png qTCKVKFPImX2BcpnSV3d.png +repage -alpha off -resize 256x256^! -metric rmse -format %[distortion] -compare info:
0.759269

im6beta convert ed3k2rBk7HZzJccH98x9.png qTCKVKFPImX2BcpnSV3d.png +repage -alpha off -resize 256x256^! -metric rmse -format %[distortion] -compare info:
0.758141


# rmse: rgb

Code: Select all

im7beta magick ed3k2rBk7HZzJccH98x9.png qTCKVKFPImX2BcpnSV3d.png +repage -resize 256x256^! miff:- | im7beta magick compare -channel rgb -metric rmse - null:
11973.6 (0.182706)

im6beta convert ed3k2rBk7HZzJccH98x9.png qTCKVKFPImX2BcpnSV3d.png +repage -resize 256x256^! miff:- | im6beta compare -channel rgb -metric rmse - null:
11972.9 (0.182694)

im7beta magick ed3k2rBk7HZzJccH98x9.png qTCKVKFPImX2BcpnSV3d.png +repage -resize 256x256^! -channel rgb -metric rmse -format %[distortion] -compare info:
0.182777

im6beta convert ed3k2rBk7HZzJccH98x9.png qTCKVKFPImX2BcpnSV3d.png +repage -resize 256x256^! -channel rgb -metric rmse -format %[distortion] -compare info:
0.182687


# rmse: rgba

Code: Select all

im7beta magick ed3k2rBk7HZzJccH98x9.png qTCKVKFPImX2BcpnSV3d.png +repage -resize 256x256^! miff:- | im7beta magick compare -channel rgba -metric rmse - null:
18727.4 (0.285761)

im6beta convert ed3k2rBk7HZzJccH98x9.png qTCKVKFPImX2BcpnSV3d.png +repage -resize 256x256^! miff:- | im6beta compare -channel rgba -metric rmse - null:
18694.8 (0.285264)

im7beta magick ed3k2rBk7HZzJccH98x9.png qTCKVKFPImX2BcpnSV3d.png +repage -resize 256x256^! -channel rgba -metric rmse -format %[distortion] -compare info:
0.285874

im6beta convert ed3k2rBk7HZzJccH98x9.png qTCKVKFPImX2BcpnSV3d.png +repage -resize 256x256^! -channel rgba -metric rmse -format %[distortion] -compare info:
0.285254