views:

74

answers:

3

Hello,

  1. How do I find the difference between 2 images?
  2. replace the difference in the second image to make both images identical?

I've found answers for the first part...but not for the first and second combined....

I would appreciate any help

Thanks so much

Edit: I'm using C#.Net

Soucrs I've found so far...

But,how do I use these to fit my need? Please help me...Thanks

+1  A: 

Are you sure that the better solution, to save bandwidth, is not to simply replace image nr. 2?

Supposing that, at least one of images is not on local and that the image size is x bytes. You have two possibilities:

  • To compare the two images, you have to: download it, compare them and the upload the new image. So you'll transfer 2x bytes on network (plus the computation time).
  • To overwrite the 2nd image, you have to: upload the new image. x bytes on network (and no computation time).
andcoz
No,only the computation time is involved ...I won't transfer the whole image...I'll only transfer the difference and update it in the first image that was already transferred
Josh
So, you have a copy of both images in local?
andcoz
yes,I'll have both the images in local
Josh
A: 

If I understood you correctly you have 1 pc with 2 images and another with 1. You want to compare images on pc1 and send the difference to pc2?

Quite an interesting task.

The only optimization algorithm that comes to mind (considering I don't know specialized algrothims for that case) is recursively dividing image into quad-tree, say NE, NW, SW, SE till your reach the certain optimal threshold and then sending to pc2 only the nodes that differ between images.

For example you have image

0000
0010
0011
0000

You divide it into the following quad-tree:

NW: 
00
00

NE:
00
10

SE:
11
00

SW:
00
00

You send following information to pc2: NE 0010 SE 1100

Considering it only takes a byte or int to specify full path (NW->NE->SW) in quadtree you will send

1(NE)+4(0010)+1(SE)+4(1100) = 10

bytes of information instead of original 16.

If you recursively divide your subtree one more time the output bandwidth is going to be 6 bytes instead of 16.

Grozz
I have everything else now...Updating pc2 with the difference is exactly what I need!!...and preferrably in C#
Josh
A: 

For part 2:

What if you stored the difference as a transparent GIF image? Then to build the final image, you just have to draw the transparent GIF on top of the other image.

David
How do I do it in C#?
Josh