Task: I have a camera mounted on the end of our assembly line, which captures images of produced items. Let\'s for example say, that we produce tickets (with some text and p
There are surely applications and libraries out there that already do what you are attempting to do, but I don't know offhand of any. Obviously, one could hash the two images and compare but that expects things to be identical and doesn't leave any leeway for light differences or things like that.
Assuming that you had controlled for the objects in the images being oriented identically and positioned identically, one thing you could do is march through the pixels of each image, and get the HSV values of each like so:
Color color1 = Image1.GetPixel(i,j);
Color color2 = Image2.GetPIxel(i,j);
float hue1 = color1.GetHue();
float sat1 = color1.GetSaturation();
float bright1 = color1.GetBrightness();
float hue2 = color2.GetHue();
float sat2 = color2.GetSaturation();
float bright2 = color2.GetBrightness();
and do some comparisons with those values. That would allow you to compare them, I think, with more reliability than using the RGB values, particularly since you want to include some tolerances in your comparison.
Edit:
Just for fun, I wrote a little sample app that used my idea above. Essentially it totaled up the number of pixels whose H, S and V values differed by some amount(I picked 0.1 as my value) and then dropped out of the comparison loops if the H, S, or V counters exceed 38400 or 2% of the pixels (0.02 * 1600 * 1200). In the worst case, it took about 2 seconds to compare two identical images. When I compared images where one had been altered enough to exceed that 2% value, it generally took a fraction of a second.
Obviously, this would likely be too slow if there were lots of images being produced per second, but I thought it was interesting anyway.