Matching an image within an image

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
richardml88
Posts: 2
Joined: 2015-09-09T13:08:13-07:00
Authentication code: 1151

Matching an image within an image

Post by richardml88 »

Hi Guys,

I've tried to do some googling, but the fact that my search term requires the use of 2 words "image", means the results aren't great. So I just thought I'd ask those in the know.

I want scan an image, visually for a match of a sample image I have. It's like facial recognition but,... more simple, because it's a fixed image. Easier with examples.

Let's say I am given this image: http://cloud-2.steamusercontent.com/ugc ... A937AD928/

I want to scan it for the global elite / supreme icons, just for reference here are the icons i'd be looking for: http://images.akamai.steamusercontent.c ... 0DE8A58F6/

I'd want to find all matches, but i'd want to know which is the biggest in size. The size of these will vary, so the matching would need to account for that. Like how possible is this through imagemagick? Are there any terms I should be searching for for sample code of image sub image matching? Any guidance would be much appreciated.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Matching an image within an image

Post by snibgo »

ImageMagick has "-subimage-search", which looks for one image at exactly that size within a larger image. It returns the closest match found. If you want to find another match, you could paint out the found area in the large image, and search again.

If the large image might contain a small image at different scales, then resize the small image before searching, and repeat the search for each scale.

If you don't know what scale the image might appear at, life is harder. My pages give some techniques.
snibgo's IM pages: im.snibgo.com
richardml88
Posts: 2
Joined: 2015-09-09T13:08:13-07:00
Authentication code: 1151

Re: Matching an image within an image

Post by richardml88 »

This is excellent. I should be able to know roughly the size of it.. I mean, the screenshots will be taken at one of like 9 resolutions.

Thank you so much, I'll take a look at this tomorrow :) exciting stuff :D
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Matching an image within an image

Post by fmw42 »

An example is at viewtopic.php?f=1&t=14613&p=51076&hilit ... ric#p51076, but moderately current versions of IM need -subimage-search added to the command line.

See also
http://www.imagemagick.org/script/compare.php
http://www.imagemagick.org/Usage/compare/

Note that the compare function does not work if the images are rotated or scaled differently.
Post Reply