Fastest way to compare pixel values between two BufferedImages?

Reading data from a VolatileImage will not be faster. What makes VolatileImages "faster" is that they use accelerated (VRAM) memory instead of system (RAM) memory for drawing images. However, when doing a read, it may need to access memory over another bus and is slower than system memory for those operations.

Reading data from a VolatileImage will not be faster. What makes VolatileImages "faster" is that they use accelerated (VRAM) memory instead of system (RAM) memory for drawing images. However, when doing a read, it may need to access memory over another bus and is slower than system memory for those operations.

The fastest way to compare BufferedImages would be to use integer comparisons the way you discuss in your post, but as you mention you can't use getRGB for performance reasons. You can get a batch of pixels into an array, but overall you should probably just peek into the Raster and DataBuffer for performance.

You are right; Volatile is a bad suggestion. I've edited that out. Sadly I can't downvote my answer.

– Mikeb Dec 29 '09 at 21:00 Your answer was good about the DataBuffer comparison :) – Kristopher Ives Dec 30 '09 at 3:12.

If both images use the same color model and sampling, you can perform your comparison on the DataBuffer of the raster, which will be a little faster.

Yes, both images use the same color model and sampling. Presumably with DataBuffer I will still need to do the bit shifting, but perhaps at least avoid ORing the values back together. – Caffeine Coma Dec 29 '09 at 17:43 If it helps at all, all of the images I am working with are "offscreen"; one is read in from a JPG, the other one is constructed from drawing into a Graphics2D.

I have never used VolatileImage before, I will check it out. – Caffeine Coma Dec 29 '09 at 18:07.

My initial approach would be taking the negative of image A and add image B.

This is an excellent idea :) – Kristopher Ives Dec 30 '09 at 10:59 This seems like a great idea, but I haven't had much luck finding examples. I assume I'd need to implement java.awt. CompositeContext.

The only implementation of that I see is SunCompositeContext, and unfortunately the source is not provided. – Caffeine Coma Dec 31 '09 at 4:34.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions