简体   繁体   中英

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?

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.

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 .

It sounds like you would want some kind of optical character recognition software. Use an OCR package to produce the text, then run a textual diff.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM