PDA

View Full Version : Bitmap data comparison - help needed!



Furinax
July 31st, 2009, 05:22 PM
Hi Everyone,

I'm looking for a good method to compare a single bitmap data instance against an array of stored bitmap data objects. I need to figure out how I can compare and arrive at the conclusion that the result either means that the images are of the same object/aka similar or if they are two totally different images. I tried checking threshold of the result of the compare() function but my efforts have failed so far. I'm not interested in posting my code because well, it's a waste of time it doesn't work so I'm hoping someone smarter than I on this matter can come along and help me out with a fresh approach!!!!! Thanks all,

Jesse

senocular
July 31st, 2009, 07:22 PM
compare() and manual pixel by pixel checking with getPixel() is about all you got

Furinax
August 1st, 2009, 02:37 AM
Sigh.... that's not gonna work because I need to compare a set of pixels to see if it's similar to the last capture (or a series of captures) but using compare I have to match dimensions which makes this a task impossible for AS3 then I guess without making the app so slow it's a complete waste of time. Sigh thanks senocular I guess I'm gonna have to do this in a custom wrapper and point data into flash :(. By the way are you like the editor for ALL of the reference material for adobe or what? I looked up creating and dispatching custom events the other day and found like a 26 page article by you on just that topic. Man dude knowing so much about all this do you ever have time for anything else? lol

pjetr
October 27th, 2011, 03:21 AM
a bit late, to answer on this thread, but you can always compare two images bij laying them on each-other using a blendmode. I think BlendMode.DIFFERENCE is the one you want.


bmpd2.draw(bmpd0);
bmpd2.draw(bmpd1, new Matrix(), new ColorTransform(),BlendMode.DIFFERENCE);

Pixels that are the same are now black. tweak this and you'll be able to compare 2 images to see if they are alike.

MJTheOne
October 27th, 2011, 03:30 AM
Or:
http://www.lextalkington.com/blog/2011/01/dynamic-mask-and-image-comparison-part-2/

bwhiting
October 27th, 2011, 05:03 AM
I would have gone for the difference method myself then work out the overall darkness of the image... the darker the result the close the images are.

Am sure there is faster way to do this but off my head you could (after a difference) run through each pixel with


var brightness:Number = 0.299*r + 0.587*g + 0.114*b; //where r g and b are extracted using get pixel

for each pixel accumulate the brightness then average it once the loop is complete.

then you can use this value to make an educated guess as to how similar the images are.

to speed it up there is no reason you couldn't down-sample the image heavily to reduce the number of calls to getPixel().