【发布时间】:2019-07-07 16:59:00
【问题描述】:
我想比较两张 JPG 图片。由于 JPG 补偿,我知道参数“fuzz”。 现在我想用蒙版比较这两个图像——我不想比较整个矩形,只比较它的一部分。 因此,我希望像素差异来计算百分比差异,并且在第二步中我想要一个图像,它显示红色/黑色的差异。
我发现这篇文章:New compare feature
我的老办法(比较整个矩形):
/usr/bin/compare -metric ae /mnt/usbstorage/tmp/15.jpg /mnt/usbstorage/tmp/14.jpg -compose src /dev/null 2>&1
=> 8432 Pixels different
我的老方法(比较整个矩形并将其绘制成图像):
/usr/bin/compare -metric ae /mnt/usbstorage/tmp/15.jpg /mnt/usbstorage/tmp/14.jpg -compose src /dev/null -highlight-color Red -lowlight-color Black /mnt/usbstorage/tmp/diff.gif
我的新尝试(将图像与蒙版图像进行比较):
/usr/bin/compare -read-mask /mnt/usbstorage/tmp/mask.png -metric ae /mnt/usbstorage/tmp/15.jpg /mnt/usbstorage/tmp/14.jpg -compose src /dev/null 2>&1
=> 8432 Pixels different
不同的像素不会改变! 8432 8432...所以我的面具不会改变任何东西!
当我执行该命令以将差异保存在新图像中时,蒙版有灰色区域,未更改像素的黑色区域和不同像素的红色区域->完美。图像很完美,像素比较保持不变。为什么?
我不明白 - 你有解释/例子吗?我做错什么了吗?
这里是文件:
【问题讨论】:
标签: compare imagemagick