Page 1 of 1

Image moved Left, Right, Up or down?

Posted: 2013-01-12T11:39:39-07:00
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

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

Posted: 2013-01-12T12:00:23-07:00
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

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

Posted: 2013-01-12T12:21:51-07:00
by cambob
So would I need to resize my secondary images, then compare master image?

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

Posted: 2013-01-12T13:11:44-07:00
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?

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

Posted: 2013-01-12T13:37:25-07:00
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.

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

Posted: 2013-01-12T13:41:54-07:00
by cambob
How would I issues these commands using the dll? or a script?

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

Posted: 2013-01-12T14:22:37-07:00
by snibgo
You can type them at the command line. Or put them in a script.

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

Posted: 2013-01-12T14:28:37-07:00
by cambob
No way to issue and get result using Dll in Visual Basic?

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

Posted: 2013-01-12T15:33:29-07:00
by snibgo
Yes, Visual Basic, or VBScript, or C, or PHP, or pretty much anyhow you want.

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

Posted: 2013-01-12T15:36:18-07:00
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:

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

Posted: 2013-01-12T16:24:07-07:00
by snibgo
There are examples on these forums, and Google finds many more.