Compare the difference of two Images.

Cited from https://rosettacode.org/wiki/Percentage_difference_between_images#Python.

 

I chose PYTHON script. But the script has some problem. I need to change “import Image” to “From PIL import Image”.

 

The output will give the pixel difference in percentage.

 

But I don’t understand the output. A more clear way is got from http://stackoverflow.com/questions/29229535/measure-similarity-of-two-images-in-java-or-imagemagick. In this method, the different pixel number will be output.

This used ImageMagick in Linux. The command to compare a.png and b.png is:

compare -metric ae a.png b.png null:

The output is the number of different pixel. If you want the percentage. You need to use the following command to get the X and Y for the image and use X*Y to calculate the total pixel. Then use the above result divided by the below result to get the percentage.

identify a.png

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s