10-06-2012 01:46 AM
Good day everyone, I just want to ask how to get the percentage difference between two binary matrices. This is for comparing two images converted to matrices in LabView. Thank you.
Solved! Go to Solution.
10-06-2012 02:17 AM
You can use the normal mathematical operators on arrays as well. I've attached an example.
10-06-2012 03:13 PM - edited 10-06-2012 03:15 PM
@pinkman wrote:
Good day everyone, I just want to ask how to get the percentage difference between two binary matrices. This is for comparing two images converted to matrices in LabView. Thank you.
You probably converted it to a 2D array (A matrix in LabVIEW has a special meaning).
"Binary" is not very well defined (unless you are looking for the number of bits that are different). What is the datatype? Was it a color image or a greyscale image? Are both arrays the same size?
How do you define "percentage difference"? Which one of the two is the 100% reference?
All possible interpretations can be easily solved with very little code, but you need to explain in more detail what you actually want?
Here is a simple solution for case #2, for example (assuming the array have the same size, and we only want a rought estimate, rounded down to the nearest integer percent):
10-09-2012 10:27 PM
I believe that's what we needed, thank you sir. The only problem is that we use a very high resoultion for the images(2562x2050), and we use it through comparing two PCB patterns in grey scale. Is there a way to exclude the zeroes in the 2d array when we obtain the percentage difference? Because when the resolution is very high, the patterns of the PCB seems too small compared to the whole PCB, so it produces a lot of zeroes against ones.
We tested to get the percentage difference between the images below(attached), we got a value of 2% even though their patterns are too different.
Your help is greatly appreciated, thank you sir.
10-09-2012 10:49 PM
I cannot see the color map. Are the zeroes white? Are all mistakes whilte?
What you can do is divide by the number of black pixels in the reference image.
Instead of "array size", use a "not equal zero" on the reference array and divide by that number instead. See if it works.
10-10-2012 01:22 AM
Yes sir, the white are zeroes and the black are ones. We threshold the images before comparing, so the white part becomes black and the black part becomes red. And sir, what do you mean by divide by the number of black pixels in the reference image? Basically, we want to compare the pixels of the red part from the two images with respect to its position.
Thank you sir.
10-10-2012 09:09 AM
So, what kind of percentage would you expect for the two images? They are not fully thresholded, because there are a significant amount of elements that are neither x000000 or xFFFFFF.
10-11-2012 10:42 PM
Sir we are trying to get the percent difference of the image with respect to the template, but we only want to compare the patterns, so it excludes all zeroes. The image is being process through thresholding before we get the percent difference.
Thank you sir.
10-12-2012 01:38 AM - edited 10-12-2012 01:39 AM
Well, in the current picture the interesting pixels are zero in the reference image. Here's a quick example that would take all zero pixels as 100%, then look at the same pixels in the other image to see how many are still 0.
Modify as needed.
10-12-2012 10:58 PM
That is what we need.
Thank you sir!
And sir, can you hel me with this one?http://forums.ni.com/t5/LabVIEW/Is-there-a-way-to-locate-segments-from-a-reference-image-to/td-p/218...