Algorithm to compare two images..?
Blitz3D Forums/Blitz3D Programming/Algorithm to compare two images..?
| ||
Does anyone has ever written an algorithm to compare two images knowing if they are similar? How could it be implemented in blitz3d? btw I need it for small images (100x100) |
| ||
You could modify this code http://www.blitzbasic.com/Community/posts.php?topic=90054 Instead of redrawing the image in the second pass you could load a different image and compare the color results. Then weigh your decision based on matches. It would be crude but might be a start. |
| ||
I would imagine that something along the lines of this (pseudocode) could work: for x = 0 to image width - 1 for y = 0 to image height - 1 get pixel color r1,g1,b1 of image 1 at x,y get pixel color r2,g2,b2 of image 2 at x,y sumtotal = sumtotal + (r1-r2)^2 + (g1-g2)^2 + (b1-b2)^2 next y next x if sumtotal < some threshold value then they are similar |
| ||
Isn't there a possibillity to make a BITBLT() from one picture to the next with a XOR-Flag? This would remain only the different pixels. Counting them would bring the result.... |
| ||
It depends on what he wants. BITBLT() with XOR will simply show different pixels when he may not care if, for instance, the 'red' pixels in 1 image are only slightly different than the 'red' pixels in the second. It depends on if he wants number of equal color value pixels, or a measure of how close the two images are, say from a scanned image or something. |
| ||
Thx It worked :) |