1

I feel like I have a very typical problem with image comparison, and my googles are not revealing answers.

I want to transmit still images of a desktop every X amount of seconds. Currently, we send a new image if the old and new differ by even one pixel. Very often only something very minor changes, like the clock or an icon, and it would be great if I could just send the changed portion to the server and update the image (way less bandwidth).

The plan I envision is to get a rectangle of an area that has changed. For instance, if the clock changed, screen capture the smallest rectangle that encompasses the changes, and send it to the server along with its (x, y) coordinate. The server will then update the old image by overlaying the rectangle at the coordinate specified.

Is there any algorithm or library that accomplishes this? I don't want it to be perfect, let's say I'll always send a single rectangle that encompasses all the changes (even if many smaller rectangles would be more efficient).

My other idea was to get a diff between the new and old images that's saved as a series of transformations. Then, I would just send the series of transformations to the server, which would then apply this to the old image to get the new image. Not sure if this is even possible, just a thought.

Any ideas? Libraries I can use?

seibelj
  • 890
  • 2
  • 10
  • 22
  • 1
    Is there a reason you are hand-rolling this, and not using [VNC](http://en.wikipedia.org/wiki/Virtual_Network_Computing) or something? – ire_and_curses Mar 19 '12 at 21:21
  • There is an extremely good reason we cannot transmit video or use VNC etc, has to be a series of images. – seibelj Mar 19 '12 at 21:38

3 Answers3

4

Compare every pixel of the previous frame with every pixel of the next frame, and keep track of which pixels have changed?

Since you are only looking for a single box to encompass all the changes, you actually only need to keep track of the min-x, min-y (not necessarily from the same pixel), max-x, and max-y. Those four values will give you the edges of your rectangle.


Note that this job (comparing the two frames) should really be off-loaded to the GPU, which could do this significantly faster than the CPU.

Note also that what you are trying to do is essentially a home-grown lossless streaming video compression algorithm. Using one from an existing library would not only be much easier, but also probably much more performant.

BlueRaja - Danny Pflughoeft
  • 84,206
  • 33
  • 197
  • 283
0

I know am very late responding but I found this question today.

I have done some analysis on Image Differencing but the code was written for java. Kindly look into the below link that may come to help

How to find rectangle of difference between two images

The code finds differences and keeps the rectangles in a Linkedlist. You can use the linkedlist that contains the Rectangles to patch the differences on to the Base Image.

Cheers !

Community
  • 1
  • 1
Nandhan
  • 195
  • 1
  • 1
  • 8
0

This is from algorithms point of view. Not sure if this is easier to implement.

Basically XOR the two images and compress using any information theory algorithm (huffman coding?)

ElKamina
  • 7,747
  • 28
  • 43