Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I compare two images in C#?

I want to try to develop an trail application in which the first image containing the some text (suppose it may be "hello World") and that image I want to compare with another image (and suppose it is "hello"). The above image comparison, I want the output there is missing "World" text.

How I will do that?

like image 655
Tirth Avatar asked Dec 09 '22 14:12

Tirth


2 Answers

That won't be as easy as you might think. If the second image is an exact copy of the first, but cropped, you can create two bitarrays and see if they overlap. If they aren't, I suggest you look at this article about OCR. Either way, this is something that's very hard to do with code and if there is any other way, I suggest you take it.

like image 72
Jouke van der Maas Avatar answered Dec 28 '22 01:12

Jouke van der Maas


The above suggestions are good if your images always contain text (to be OCRed). A more generic application would be to use a library like OpenCV - it gives you a number of ways of extracting features (edge, shape, color etc.) from the images and comparing them.

An even simpler method would be to use the OpenCV template matching method which "compares" one image (template) to another.

Since you are on C#, you should look at Emgu .NET wrapper for OpenCV.

like image 31
Mikos Avatar answered Dec 28 '22 02:12

Mikos