Jump to content
  • Advertisement
Sign in to follow this  
overeasy

[java] Comparing buffered images in Java

This topic is 2558 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Heyo,

I am trying to compare buffered images using databuffers. Both images are subimages of a larger image. Any reason this should fail?

I think because they are using the same data (subimage does not create a new image really) I cannot compare them in this fashion - it even says two areas of black are unique.

I tried using a raster, with no success.

Suggestions?

Share this post


Link to post
Share on other sites
Advertisement
Any chance you could post some code showing how you test for equality?

Are you comparing the BufferredImages you get back from getSubImage() or the underlying image data ??

Share this post


Link to post
Share on other sites
comparing two objects using the == operator will only tell you if one object is a reference of another, not if they contain the same data.

Some objects have a .equals method you can use instead to make a comparison of the content.

Share this post


Link to post
Share on other sites

Any chance you could post some code showing how you test for equality?

Are you comparing the BufferredImages you get back from getSubImage() or the underlying image data ??




comparing two objects using the == operator will only tell you if one object is a reference of another, not if they contain the same data.

Some objects have a .equals method you can use instead to make a comparison of the content.


I will post the code shortly. Basically I was using .getDataBuffer .getRaster and going through the images. To eliminate the possibility that I was looking at the image data, I am now creating a new BufferedImage and drawing on the section of the old buffered image. Still having false negatives, where it says two subsections are different when they are in fact the same.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!