Sign in to follow this  
overeasy

[java] Comparing buffered images in Java

Recommended Posts

overeasy    100
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
Angex    884
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
SimonForsman    7642
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
overeasy    100
[quote name='Angex' timestamp='1310898265' post='4836312']
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 ??
[/quote]


[quote name='SimonForsman' timestamp='1310906696' post='4836353']
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.
[/quote]

I will post the code shortly. Basically I was using .getDataBuffer .getRaster and going through the images. To eliminate the possibility that I [i]was[/i] 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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this