DEV Community

Atir Tahir
Atir Tahir

Posted on • Originally published at blog.groupdocs.com

How to compare two images in C# .NET

GroupDocs.Comparison is a document comparison API that correlates content and style, it detects number of inserted/deleted or style changed items and generates a summary.

How GroupDocs.Comparison works for Image Comparison?
The comparison starts with the upper left corner and compares the entire image pixel by pixel. If the pixels are the same, it moves on to the next one and so on until it finds a difference. The changed pixels are given an ID. It is defined as dabbed, deleted or changed. They are highlighted in a specific color (blue, red or green according to the standard settings).

Source Image
Alt Text

Target Image is same as source image except it has some extra objects on the table and some new code lines in the text editor.
Alt Text

Comparison Result
Alt Text

API successfully detects the changes and highlights them in the output/resultant image. In this case it highlighted the inserted items (e.g glasses, mug and some changes in the code).
This is how you do image comparison using GroupDocs.Comparison for .NET

Get access to the API resources.

Top comments (2)

Collapse
 
jckodel profile image
J.C.Ködel

Visual comparison is kinda useless. This algorithm works fine, it generates a small reliable image hash: codeproject.com/Articles/374386/Si...

Collapse
 
atir_tahir profile image
Atir Tahir

Not useless at all if you are looking for a quick image comparisons solution. Or if you just want to point out where is the difference, visually.