开发者

Difference between 2 images based on pixel comparison

How can I find t开发者_运维百科he difference between two images based on the pixel difference?


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.


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.


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);


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/


You could implement a Sobel Filter

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜