• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

See if one picture is exactly like another...

 
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 802
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic