|Just another Perl shrine|
comparing two images and detecting differencesby moof1138 (Curate)
|on Dec 31, 2003 at 01:24 UTC||Need Help??|
moof1138 has asked for the
wisdom of the Perl Monks concerning the following question:
Greetings kind monks. I collect ancient coins, mostly Greek and Roman. While counterfeits are not common from brick and mortar dealers, unfortunately there are some counterfeits occasionally sold on eBay (mostly cast copies). Fortunately there are many image collections of known forgeries that a collector can use to check up on coins, but they are a pain to work with as there are hundreds of images to scan.
I was thinking about writing a tool in Perl that took a given image, resized it appropriately, and compared it to a set of images and if the images were similar, then present the original image and the counterfeit for human verification. It would be easy to build up a large image library of counterfeits, and many times identical images are used by sellers, so often counterfeits would be an exact match.
When I thought more about the problem I figured I might be in over my head, and I did not see anything on CPAN that did exactly what I was interested in (though perhaps I missed something).
I was thinking I could crop the images to the edges of the coin and resize both, but was not sure if content based cropping was possible. Alignment is not a problem since images are almost always aligned top to bottom. If I could get that far I could use Image Magick, create a negative of one of the images and then composite them, then test the composite image. I am not exactly sure how to test the results off the top of my head, but I think this is something I could sort out. I wanted to know if any monks knew of a CPAN module, a different library that might be useful for this sort of task, or if there is a better approach to take. If anyone has done anything similar and could give me any pointers I would really appreciate it, this particular topic seems to be a real pain to find the right keywords to search for.
There are a lot of folks who are really upset by forgeries and I would really like to make a CGI or a tool available to collectors that they could use to test images. If I made a CGI that did this I could get it hosted for free and I think it would be valuable to a lot of collectors who are currently intimidated by the threat of counterfeits (even though they areally are not that common, even on eBay).
Many thanks for any advice you might have to offer.