aspose file tools*
The moose likes Beginning Java and the fly likes See if one picture is exactly like another... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "See if one picture is exactly like another..." Watch "See if one picture is exactly like another..." New topic
Author

See if one picture is exactly like another...

Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
Is there a way in java to see if a picture is exactly like another? Such as pixels, width, height, color of the pixels.

for example:

picture.equals(picture2);


Justin Fox


You down with OOP? Yeah you know me!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41880
    
  63
There is nothing predefined like this, but you can easily write this yourself. Use the javax.imagio.Imageio.read method to load both images, and then use the methods of the BufferedImage class to compare widths, heights and RGB values.


Ping & DNS - my free Android networking tools app
Chad Clites
Ranch Hand

Joined: Aug 16, 2005
Posts: 134
Alternatively, you could also generate an MD5 hash of both images and compare the hashes. This method would not tell you specifically what is different though.
[ December 27, 2007: Message edited by: Chad Clites ]
Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
cool, thanks a lot.

what I'm wanting to do is, I have a game I play(mmorpg) and you kill "monsters" and stuff, and what i was going to do was take certain screencaptures with the robot class and compare them to a static picture I took and saved, if they are alike, attack that "monster".

This might not be a good way, because the likely hood of me randomly taking a screen capture that is exactly alike is almost impossible.

I had another plan though:

have about 5 or 6 different threads and have them "scanning" a current copy of the gamescreen, If i come across a certain pixel color that is that of a "monster" attack that creature, and pause all other threads.

Is this a good approach?

Thanks,

Justin
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: See if one picture is exactly like another...