Using compare with subimage cannot return proper result

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
yuexin
Posts: 2
Joined: 2016-05-18T09:24:20-07:00
Authentication code: 1151

Using compare with subimage cannot return proper result

Post by yuexin »

Hello

I am new to ImageMagick, so right now I simply apply "compare.exe -subimage-search" to compare two images, most of times it returns the proper result, but sometimes it will return the offset even these two images are totally different. It seems the compare program detected several matched pixels, may I know how to get the overall score of the matched pixels? Is it possible in ImageMagick?

Thanks in advance.
Yuexin
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Using compare with subimage cannot return proper result

Post by snibgo »

"compare -subimage-search" finds the best match for the small image within the large image. This may not be a perfect match, or even a good one.

For example, searching for a 10x10 red image within "rose:":

Code: Select all

f:\web\im>%IM%convert -size 10x10 xc:red r.png

f:\web\im>%IM%compare -subimage-search -metric RMSE rose: r.png NULL:
12260.4 (0.187082) @ 32,9
The best match is at (32,9). But the RMSE score is 0.187, which isn't very good. (0.0 means a perfect match.) As a rule of thumb, for ordinary photos, I find that when an RMSE score is greater than 0.01 I can readily see the difference between the images.
snibgo's IM pages: im.snibgo.com
yuexin
Posts: 2
Joined: 2016-05-18T09:24:20-07:00
Authentication code: 1151

Re: Using compare with subimage cannot return proper result

Post by yuexin »

I tried to the following command
"compare.exe -subimage-search -dissimilarity-threshold 0.15 -metric RMSE tmp\click1463634949831.png 1463635754111.png result-%d.jpg"
the result is "8815.7 (0.134519) @ 11,1" for instance.
It seems the result is better than without the RMSE parameter, but what I worried now is the execution velocity is definitely faster than without one, so does it indicate the compare tried to use RMSE as the identification flag to filter result and didn't try to detect the subimage?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Using compare with subimage cannot return proper result

Post by snibgo »

I don't know what the default "-metric" setting is. You can use any metric you like. See http://www.imagemagick.org/script/comma ... php#metric
snibgo's IM pages: im.snibgo.com
Post Reply