BufferedImage Comparisons

Posted on 2005-05-03
Last Modified: 2012-06-27
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?

Question by:lomidien
    LVL 86

    Expert Comment

    LVL 15

    Accepted Solution

    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).

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Suggested Solutions

    If you have upgraded to Java2 update 10 on a Microsoft Windows client, you may have discovered that your Java application does not work as it did before.  For example, the colors of your Java2D graphic may be all wrong for no apparent reason. Aft…
    Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
    Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
    This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now