Automatically Overlay Similar Images

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
jmac698
Posts: 48
Joined: 2013-12-20T01:57:16-07:00
Authentication code: 6789

Automatically Overlay Similar Images

Post by jmac698 »

Hi,
Say I have two versions of an image in different sizes and crops. I want to resize the smaller image and overlay it on top of the larger image in the best match, but have it opaque only in the places they differ. So imagine I have a large cartoon character with a text bubble, and a smaller version without the text bubble. I want to erase the text bubble by resizing the smaller image and placing it on top of the larger, but opaque only where they differ, which would be the text bubble.

Since they will differ almost everywhere because one version is essentially blurred, instead I can find the difference by resizing the large image down to the smaller image and they should be much more similar then, find the mask, then resize the mask and compose the images as above.

It's pretty complicated!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Automatically Overlay Similar Images

Post by snibgo »

The essential problem you need to solve is: given two images, where one is a resized crop of the other, but also with some differences to the image (eg no speech bubble), you need to find the crop and scale parameters that would register the two images.

Once you know those parameters, you would register one image to the other, and do what you want with the differences.

Finding multiple unknown is always tricky. Do your images contain lots of detail, like ordinary photographs? If they did, then finding corresponding points of detail would be quite fast, so that would give you the scale, and then finding the crop would be easy.

That technique might still work for cartoons that contain large areas of flat colour, perhaps by first finding edges.

Failing that, trial-and-error at different scales should work.

My pages address many aspects of this problem, but aimed at photographs rather than cartoons.

If you put up a couple of samples, I might have more ideas.
snibgo's IM pages: im.snibgo.com
Post Reply