Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an algorithm to detect the differences between two images?

I'm looking for an algorithm or library that can spot the differences between two images (like in a "find the errors" game) and output the coordinated of the bounding box containing those changes. I'm open to the algorithm being in Python, C, or almost any other language.

like image 234
Phil B Avatar asked Mar 23 '23 14:03

Phil B


2 Answers

If you just want to show the differences, so you can use the code below.

FastBitmap original = new FastBitmap(bitmap);
FastBitmap overlay = new FastBitmap(processedBitmap);

//Subtract the original with overlay and just see the differences.
Subtract sub = new Subtract(overlay);
sub.applyInPlace(original);

// Show the results
JOptionPane.showMessageDialog(null, original.toIcon());

For compare two images, you can use ObjectiveFideliy class in Catalano Framework. Catalano Framework is in Java, so you can port this class in another LGPL project.

FastBitmap original = new FastBitmap(bitmap);
FastBitmap reconstructed = new FastBitmap(processedBitmap);

ObjectiveFidelity of = new ObjectiveFidelity(original, reconstructed);

int error = of.getTotalError();
double errorRMS = of.getErrorRMS();
double snr = of.getSignalToNoiseRatioRMS();

//Show the results

Disclaimer: I am the author of this framework, but I thought this would help.

like image 59
Diego Catalano Avatar answered Apr 06 '23 20:04

Diego Catalano


There are many, suited for different purposes. You could get a start by looking at OpenCV, the free computer vision library with an API in C, C++, and also bindings to Python and many other languages. It can do subtraction easily and also has functions for bounding or grouping sets of points.

Aside from simple image subtraction, one of the specific uses addressed by OpenCV is motion detection or object tracking.

You can ask more specific image-related algorithmic related questions in the Signal Processing stackexchange site.

like image 20
sinelaw Avatar answered Apr 06 '23 21:04

sinelaw