On image comparison

Started by
30 comments, last by _nomad_ 19 years, 10 months ago
i''m trying to use this:

http://www.cs.nott.ac.uk/~smx/iviPracticals/prac8.html


and i''ve tried using the given sample images, but i still get wrong results...any one here want to try this out also and see if i coded wrongly or is the algorithm just simply wrong?

thanks.
Advertisement
If the eye picture is exactly the same exceot for hair etc ( as opposed to there being differences in lighting, attitude etc) and they are to identical scale:

Find a ''signature'' in the eye image - ie look at a group of pixels at the corner of the eye like a 4x4 section. Then search the main image for this. You can have many signaure points, as soon as you find the same one (or maybe need 2-3 to be sure) in both images you can place it.
@d000hg - hi, could you elaborate more on the signature point part? how does one extract signature points from the two images and compare these points? thanks.

also, if anyone knows of any general algorithm for image comparison (not just for eyes), please suggest some. what i''ve tried so far is SSD (sum of squared difference) and histogram matching and a combination of SSD and histogram matching, and still, it fails.
I''ve not used this idea but it should work:

Choose a point on the eye/nose/etc image (unobstructed by stuff). Then read the rgb value at some pixels on/around this - maybe all the pixels in a 3x3 rectangle around this point or a selection of points in a 10x10 rectangle. Then on the main image you search for this pattern (I can explain a simple way but will assume you are OK unless you ask). If you find it, you know exactly where the desired feature is on the full image. This technique will only work if the two images are to exactly the same scale ie you''ve got the eye image ''pasted'' into a face and drawn hair over it. Because the signature point may be obscured, you either need to make it large (choose 50 pixels over the eye and require to match 35) or have a few small points say at each ''corner'' of the images. The only problem comes if you have e.g two identical eyes, but if you find two eyes or an eye and a nose you can solve this trivially.

Is this helpful - what exactly is it you are trying to use this for?


Read about my game, project #1
NEW (18th December)2 new screenshots, one from the engine and one from the level editor


John 3:16
quote:Original post by d000hg
Is this helpful - what exactly is it you are trying to use this for?



i''m trying to use this for an automatic sprite generation tool...where i have different animation frames for a sprite, but i don''t want to store each frame, i wish to reconstruct the frame through its parts (ie, given frame #1, construct the robot sprite using the set of parts that it is made up of).

I have the animation frames, as well as the parts that the sprite is made up of (hands, head, etc)...problem is, some frames have different parts covering different parts...

am i going about this right? or am i searching for the wrong solution?

thanks.
Well, that is certainly the wrong solution I had a program that did this back in my Amiga days and it was very simple, basically it just checked moving vertical and horizontal scanlines for collision with non-transparent pixels. When the entire picture had been scanned, you could intersect the hits to get fitted AABBs for each sprite. But any good sprite artists puts each frame inside a uniformly sized box anyway, so you should just need to read the image in in appropriately sized blocks really.
quote:Original post by GameCat
Well, that is certainly the wrong solution I had a program that did this back in my Amiga days and it was very simple, basically it just checked moving vertical and horizontal scanlines for collision with non-transparent pixels. When the entire picture had been scanned, you could intersect the hits to get fitted AABBs for each sprite. But any good sprite artists puts each frame inside a uniformly sized box anyway, so you should just need to read the image in in appropriately sized blocks really.



hi, sorry, but could you elaborate on this a bit more? i have the animation frames, as well as the parts that makes up the character...and i need to make the parts be in correct x/y location to make it look exactly like the animation frame...how did you go about this? do you have some sample source that i could see?

thanks!
_nomad_: Instead of computing a histogram for the entire color of the pixel, calculate it using only the red channel (for example). Instead of (2^8)^3 colors, there would only be 2^8 colors. Then do it again for green, and blue (or HSL), and if all 3 pass whatever comparison test you''d be doing (instead of comparing color vs color, you''re comparing red vs red, blue vs blue, and green vs green, and all 3 must pass the test for it to pass). It should be trivial to get the color channel data from whatever image format you''re using, and from there it should be trivial to treat it as if it were 3 grayscale images instead of 1 RGB image.

Really though, I suggest you make a sprite editor that lets you place the parts and stores them in the format you need, instead of reverse engineering premade sprites into parts.
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
One girl in my year did her honours project on this - well, actually it was biometrics using iris recognition, but it involved finding eyes in photos of faces.

Basically her approach was to find all circles of appropriate size to be either pupils or irises, using a Hough transform, then find a pupil/iris combo with the same or very similar centers.
quote:Original post by _nomad_
hi, sorry, but could you elaborate on this a bit more? i have the animation frames, as well as the parts that makes up the character...and i need to make the parts be in correct x/y location to make it look exactly like the animation frame...how did you go about this? do you have some sample source that i could see?

thanks!


No, sorry, I misunderstood what you were trying to do, that is indeed more complex. Why didn''t you get the correlation approach to work? Seems like the way to go provided you know the extents of the parts you''re trying to find and there''s no rotation going on.

This topic is closed to new replies.

Advertisement