2

How can I find the difference between two images based on the pixel difference?

  • 1
    Things that could help people help you: What programming language are we talking about, how are the images represented, do you just want to know that the images are different (the result is a boolean) or somehow compute something more subtle than a boolean that indicates how resembling the images are? – Pascal Cuoq Jan 5 '10 at 9:48
  • Bidimmentional Fourrier Transform helps alot in cases like this. – alemjerus Jan 5 '10 at 9:56
5

There are a lot of methods, ranging from several lines of code to a big project.

You can try:

  1. The pixel-level difference, i.e. image matrix A - image matrix B

  2. The color histogram difference. You can also split the images into several small windows, and aggregate histogram difference in each window.

  3. Exact features, like Gist, Sift etc. That's the state-of-the-art/research approach.

|improve this answer|||||
0

You can use compare tool that is part of ImageMagick.

compare -metric MSE image1.png image2.png difference.png

It will highlight differences in the third file and also output numeric estimation of the difference.

If you're interested in finding difference between images that is closer to human perception, then look for SSIM/DSSIM tools.

|improve this answer|||||
0

there is not any specific method for pixel comparison but i will try to help you....

note-> http://php.net/manual/en/book.image.php contains all required function regarding image process,i must say they represent very carefully and beautifully.

// Setup the true color and palette images
$im1 = imagecreatefrompng('orginal_image.png');
$im2 = imagecreate(imagesx($im1), imagesy($im1));

// Add some colors to $im2
$colors   = Array();
$colors[] = imagecolorallocate($im2, 255, 36, 74);
$colors[] = imagecolorallocate($im2, 40, 0, 240);
$colors[] = imagecolorallocate($im2, 82, 100, 255);
$colors[] = imagecolorallocate($im2, 84, 63, 44);

// Match these colors with the true color image
imagecolormatch($im1, $im2);

// Free from memory
imagedestroy($im1);
imagedestroy($im2);
|improve this answer|||||
0

Open Visual Studio. =>New Project

Select Visual C# => Console Application

Tools => Nuget package Manager. => Nuget Package manager for solution

Find EmguCV under Browse and install.

Under the Program.cs

using Emgu.CV;
using Emgu.CV.Structure;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace diffOfImages
{
    class Program
    {
        static void Main(string[] args)
        {
            Image<Bgr, byte> img1 = new Image<Bgr, byte>(@"d:\temp\temp1.jpg");
            Image<Bgr, byte> img2 = new Image<Bgr, byte>(@"d:\temp\temp2.jpg");
            var theDiff = img1.AbsDiff(img2);
            theDiff.Save(@"d:\temp\theDiff.jpg");
        }
    }
}

Press F5

or

see https://www.raymond.cc/blog/how-to-compare-the-difference-between-two-identical-looking-images/

|improve this answer|||||
-1

You could implement a Sobel Filter

You can implement filters like that pretty quickly in C# using the AForge framework

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.