BufferedImage Comparisons

If I have 2 sequential screenshots stored as BufferedImages, is it possible to compare them to get the differences.  I'd like to take the differences and send them over a socket to a server and be able to reconstitute the image on the fly.  Essentially I'd only be transmitting image changes so that i can achieve a more efficient "stream".  On the server side, i would accept the differences and apply them to the current image.

1) send initial image from client to server
2) client takes new picture and compares with previous
3) image differences are sent to server
4) server takes differences and applies to previous image

I hope that my question is clear.  What type of data storage object would be efficient for thsi?  Just a simple array as is used as the data backing of a BufferedImage?

Thanks,
David
lomidienAsked:
Who is Participating?
 
aozarovCommented:
on the server you can get the current and previous BufferedImage pixels by calling their getRGB method.
then you can compare one to the other an populating a new array (the same length) by putting the delta of the two (hopefully many will be zero).
Then you can run some compression on that (like Run length encoding or similar) and send it to the other side which will decompress it and add the deltas array to its current buffer.
I advice you to send the full image from time to time (every X frames) as a correction mechanisim (TV broadcasting does it as well).
0
 
CEHJCommented:
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.