Unable to get -subimage-search to work

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Xyresic
Posts: 1
Joined: 2020-03-24T14:26:15-07:00
Authentication code: 1152

Unable to get -subimage-search to work

Post by Xyresic »

I been trying for the past few hours trying to get subimage-search to work, and at this point I'm convinced there's something broken with imagemagick. Admittingly, I am using WSL on Windows, but I've also tried the Windows binaries (the v7 binaries though, instead of the default v6 from the package manager in WSL Ubuntu) and that gave the same error.

Even trying to follow something as simple as this post isn't working: https://stackoverflow.com/questions/318 ... ux-console

This is what I see when I try that:

Image

I'm pretty sure there's nothing wrong with the images I'm using, but here they are anyways:

Image

Image

Anyone have any ideas what's wrong here?

User avatar
fmw42
Posts: 26261
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Unable to get -subimage-search to work

Post by fmw42 »

You need special processing for compare when using transparency. You need to separate the alpha channel from the reference (small) image and use it as a mask on the opaque version of the reference. The command is different also. But it only works in IM 7. See https://imagemagick.org/discourse-serve ... =4&t=31053

P.S. IM 6.9.7.4 is ancient (over 3 years old and many versions and enhancements). Time to upgrade.

snibgo
Posts: 12894
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Unable to get -subimage-search to work

Post by snibgo »

Xyresic wrote: compare.exe: images too dissimilar `haystack.png' @ error/compare.c/CompareImageCommand/1170.
For that problem, use "-dissimilarity-threshold 1". See https://www.imagemagick.org/script/comm ... -threshold
snibgo's IM pages: im.snibgo.com

Post Reply