01-31-2013 04:57 AM
I have 2 pictures, I want to calculate the percentage of difference between them. For example, this 2 are similar, I want the program get a low difference percentage. But if they are totally different, the program show give percentage difference of 100.
I try to use match pattern VI, but they didn't give out the percentage of difference.
So, which VI should I use?
01-31-2013 05:10 AM - edited 01-31-2013 05:14 AM
Ok, a couple of options come to mind:
1. Think of your image as an array of numbers (pixels with a brightens value). You could work out how many of your pixels in one image are different from the same pixel in another image. It depends on how low a level you are looking when you say 'different', is one level of gray difference different enough?
2. You could subtract one image from another and see what is left over, then do some calculations on that.
3. Have a look at the golden template matching VI. There is a good example using logo inspection.
It depends what you mean by different. Do you have some example images which you could post?
01-31-2013 10:35 PM
hi, I'm using the 2nd way, but after subtracting, how to do the calculation?
the 2 images I use are in same format, taken by the same carmera, only in differnent scene.
02-01-2013 02:52 AM
Ok, so I have not recreated and tested your code, but I assume it will provide you with an image which shows the differences between the original two?
If this is the case, then all you need to do is count how many pixels have changed, and compare that with the total number of pixels in the image. Work the percentage difference out from here.
The image to array vi might be useful.
Give it a try and see if it gives you the sort of numbers which you would expect to see.
02-21-2018 11:31 PM
How to get the percentage difference of 2 images and how to get difference size btween them
02-22-2018 02:42 PM
Let me ask another question: What is the difference in percentage between a Ford T Model and a Ford Mustang? Or between a Tesla Model S and a Toyota Yaris?
You see without specifying what consist in a difference and how to quantify every difference, you can not come up with any number for a question like that.
You could convert each picture into its luminance only and simply compare the luminance of each pixel and quantify that to the total number of pixels. That is a valid number but could end up with a difference close to 0 for pictures which you would not consider similar at all when looking at them. On the other hand two pictures which are almost identical but skewed for a few pixels could give you a very high difference value that way while the human eye will consider them very similar.
Is a picture that shows 25 volleyballs similar to a picture that shows 25 apples? Taken in a certain way so the apples happen to be positioned in pretty much the same spots than the volleyballs and using a numeric approach, it may seem so but if you look at it you will certainly not consider them very similar when looking at them.
02-22-2018 03:00 PM
Also don't forget transformations. If you compare a picture with the same picture turned upside down, it is still the same picture, so should give you a 100%, right?
Imagine you have a gray scale image of a face and you increment each pixel by +1, it would still look identical even though every single pixel is different. Make sure your algorithm agrees.