0 votes
1 view
in AI and Deep Learning by (44.6k points)

My objective is to supply 2 image files and get a true/false response as to whether these 2 files could be the same (within an acceptable degree of certainty).

I realize this question falls under artificial intelligence and is much more complex than it appears, so I highly doubt I could (or would even want to) do it myself. What I'm looking for is probably a library or a class. I'm working with PHP.

thanks in advance.

Update:

I wonder if I'm over-complicating it, and maybe a more general library like ImageMagick (Imagick) could get it done? Anyone who's more experienced with ImageMagick?

1 Answer

0 votes
by (96.2k points)

As of PHP developers, the most complicated image problem we have to deal with is how to resize an upload with an acceptable loss of quality. There are two common ways of thinking about images. 

  1. The first is as a grid of individual pixels, composed of varying levels of color and contrast. Generally, we break these colors down into their constituent red, green, and blue values. We could also study them as hue, saturation, and lightness.

  2. The other way of thinking about images is in terms of vectors. A line isn’t the pixels in between but rather a starting point and an ending point, with some metadata that describes a stroke in between. We’re going to focus on bitmaps because they’ll make the whole process easier.

http://tineye.com/ may be useful if you're just comparing your images.

You should probably do some research on image similarity algorithms, though anything advanced isn't going to suit a scripting language like PHP. The most uncomplicated comparison technique would work like this:

  • Select both images the same size if they are not already.

  • Examine each corresponding pixel and decide how similar they are. The simplest method is to take the difference between the red values, then the blue values, then the green values, and average them.

  • Take the average variation from all the pixels. If it's under some threshold you decide, then the images are the same or similar. You'd require to test with various images to decide on a threshold.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...