【发布时间】:2022-01-19 02:29:49
【问题描述】:
我已经看到 Mark Setchell (https://stackoverflow.com/users/2836621/mark-setchell) 的答案,它似乎已经过时并且不再起作用了。 How to search an image for subimages using linux console?
https://stackoverflow.com/a/31874879/17686212 How to search an image for subimages using linux console?
下载针头并创建干草堆图像并将针头“隐藏”在其中工作正常。 Needle Image
convert -size 256x256 gradient:lime-blue haystack.png
convert haystack.png needle.png -geometry +30+5 -composite haystack.png
convert haystack.png needle.png -geometry +100+150 -composite haystack.png
运行指定的比较图像命令会导致错误:
compare -metric RMSE -subimage-search haystack.png needle.png locations.png
compare: images too dissimilar `haystack.png' @ error/compare.c/CompareImagesCommand/1166.
我尝试应用 -similarity-threshold 和 -dissimilarity-threshold 并更改/降低了转换位置阈值,但没有成功,也就是这样的糟糕结果:
compare -similarity-threshold 0 -dissimilarity-threshold 1 -metric RMSE -subimage-search haystack.png needle.png locations.png
convert locations-1.png -threshold 95% txt: | grep white
locations-0.png locations-1.png
我在 gentoo 上使用了 imagemagick 版本 7.1.0.14,在 kali Linux 上使用了 6.9.11.60+dfsg-1.3
希望你能帮我解决这个问题。
【问题讨论】:
-
如果使用 IM 7,则使用
magick compare而不是compare -
使用 IM 7,您可以进行蒙版比较,如果您为针状图像创建蒙版,这样大量的白色不会与大海捞针图像的绿色和蓝色不匹配。见legacy.imagemagick.org/discourse-server/…
标签: imagemagick