Using Imagick to compare image

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Post Reply
kenau898
Posts: 2
Joined: 2014-01-27T00:29:50-07:00
Authentication code: 6789

Using Imagick to compare image

Post by kenau898 »

Good day all,

I am developing a web application capable of extracting a portion of an form image and compare it with the same image but has "ticks" selection made on the form. I understand that Imagick has a compare function i could use, but I would like to specific the exact coordinates to do the comparison.

Hope to get some advise.

regards,
Ken
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Using Imagick to compare image

Post by Bonzo »

You need to supply a few more details Ken - IM version and platform - and a sample image is always helpful.
I assume as you have posted in the Imagick section you are using that API?
kenau898
Posts: 2
Joined: 2014-01-27T00:29:50-07:00
Authentication code: 6789

Re: Using Imagick to compare image

Post by kenau898 »

Hello Bonzo,

Thank you for replying. I am working on PHP and using Imagemagick 6.8.8-3. Working in XAMPP environment.

I am thinking to extract the difference based on a specific coordinates and compare with the based image to see if a "tick" is present. Attached is a cropped image of the image file where user will have to tick the check boxes.

Hope it help clear the doubt and looking forward to your reply!

thank you!
ken
Attachments
snip.JPG
snip.JPG (11.06 KiB) Viewed 7978 times
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Using Imagick to compare image

Post by fmw42 »

This is in command line but could be run from PHP exec(). I do not know how to convert to Imagick.

Image
Image

1) warp snip2 to match snip1 (the viewport makes them the same size and the affine does the warp to align them according to control points I picked manually)

convert snip2.jpg -virtual-pixel black -define distort:viewport=228x127+0+0 +distort affine "151,16 151,14 188,16 188,14 151,109 151,107 188,109 188,107" snip2_warp.png

Image

2) get the difference image

convert snip1.jpg snip2_warp.png -compose difference -composite -auto-level snip12_diff.png

Image
Post Reply