Image moved Left, Right, Up or down?

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
cambob
Posts: 11
Joined: 2013-01-12T11:32:05-07:00
Authentication code: 6789

Image moved Left, Right, Up or down?

Post by cambob »

I have a master image and I want to compare to like images to see if the like image has moved left, right, up or down from the master. Is this possible with Imagemagick?

I'm using VB6 with COM DLL
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Image moved Left, Right, Up or down?

Post by fmw42 »

You can use compare on two different image of the same size to see if different, but not the direction. But you can use one larger image and a smaller image to find the best match and offset using compare as well.

see
http://www.imagemagick.org/script/compare.php
http://www.imagemagick.org/Usage/compare/ (see section on statistics for fuzz metric)


An old example is at
viewtopic.php?f=1&t=14613&p=51076&hilit ... ric#p51076

but you now need to add -subimage-search to inform IM that the two images are different sizes. see
http://www.imagemagick.org/script/comma ... age-search

If the search bails without a match, you may also need to use -dissimilarity-threshold. see
http://www.imagemagick.org/script/comma ... -threshold
cambob
Posts: 11
Joined: 2013-01-12T11:32:05-07:00
Authentication code: 6789

Re: Image moved Left, Right, Up or down?

Post by cambob »

So would I need to resize my secondary images, then compare master image?
cambob
Posts: 11
Joined: 2013-01-12T11:32:05-07:00
Authentication code: 6789

Re: Image moved Left, Right, Up or down?

Post by cambob »

I found this at one of the links you suggested. (http://www.imagemagick.org/Usage/compare/#camera)

I am getting an "average" difference for all the images and then if the individual difference is greater than the average difference I keep the image as it has something in it.

How would I do this?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Image moved Left, Right, Up or down?

Post by snibgo »

cambob wrote:I have a master image and I want to compare to like images to see if the like image has moved left, right, up or down from the master. Is this possible with Imagemagick?
Yes. One method is to crop a small area from the "other" image, and search for that in the master. If it occurs in the same place, it hasn't moved.

Code: Select all

convert other.jpg -crop 100x100+300+400 crop.png
compare -metric RMSE master.jpg crop.png -subimage-search null:
An output of "0 (0) @ 300,400" means there is no change.
snibgo's IM pages: im.snibgo.com
cambob
Posts: 11
Joined: 2013-01-12T11:32:05-07:00
Authentication code: 6789

Re: Image moved Left, Right, Up or down?

Post by cambob »

How would I issues these commands using the dll? or a script?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Image moved Left, Right, Up or down?

Post by snibgo »

You can type them at the command line. Or put them in a script.
snibgo's IM pages: im.snibgo.com
cambob
Posts: 11
Joined: 2013-01-12T11:32:05-07:00
Authentication code: 6789

Re: Image moved Left, Right, Up or down?

Post by cambob »

No way to issue and get result using Dll in Visual Basic?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Image moved Left, Right, Up or down?

Post by snibgo »

Yes, Visual Basic, or VBScript, or C, or PHP, or pretty much anyhow you want.
snibgo's IM pages: im.snibgo.com
cambob
Posts: 11
Joined: 2013-01-12T11:32:05-07:00
Authentication code: 6789

Re: Image moved Left, Right, Up or down?

Post by cambob »

Do you know where I can get a sample of its use using commands in VB?
convert other.jpg -crop 100x100+300+400 crop.png
compare -metric RMSE master.jpg crop.png -subimage-search null:
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Image moved Left, Right, Up or down?

Post by snibgo »

There are examples on these forums, and Google finds many more.
snibgo's IM pages: im.snibgo.com
Post Reply