Results 1 to 8 of 8
Thread: xor two images to get difference
- 04-07-2009, 09:43 PM #1
Member
- Join Date
- Apr 2009
- Posts
- 3
- Rep Power
- 0
xor two images to get difference
Hi I'm writing a client/server remote viewer application where screenshots of the desktop are sent across the network over a socket. I'd like to reduce the size of the transfer by getting the difference between the two images and then sending the difference.
I'd just like to know how would i do this is there already a ready made class that can do this or would i have to implement my own and if i do how would i do this?
- 04-08-2009, 12:28 AM #2
A typical method is to split the files into chunks and send a cryptographic hash (MD5, SHA) of each. If the hashes are different then those chunks are different.
You could look at how MPEG videos work in terms of frame-difference. There are a number of reference (or "I") frames and other frames which encode the difference between them.
A completely different approach is to directly send the screen-update messages across the network. Depending on the platform you could use VNC or XWindow commands.
- 04-08-2009, 12:36 AM #3
Member
- Join Date
- Apr 2009
- Posts
- 3
- Rep Power
- 0
I want to be able to XOR the images and send the differences how do i do this in java?
- 04-08-2009, 02:07 AM #4
If you xor two images, you will get another image the same size as the original. You won't reduce the transfer size by doing that.
You need to isolate which parts of the image have changed, and send only them, or abstract instructions of how to get to the new image from the old one (e.g. add a line here, some text here, skew by this amount).
Anyway, to XOR two images, you can use PixelGrabber or some other method of getting the underlying pixel values and work through them in a loop.Last edited by OrangeDog; 04-08-2009 at 02:10 AM.
- 04-08-2009, 02:28 AM #5
Member
- Join Date
- Apr 2009
- Posts
- 3
- Rep Power
- 0
Thanks for the reply. Can you give me some example code to xor two images together?
- 04-08-2009, 02:52 AM #6
The only use for this would be a bit-by-bit check of whether an image has changed - requiring unnecessary amounts of processing compared to the methods I have already outlined.Java Code:int[] image1; int[] image2; BufferedImage result; // instantiate result // fill arrays using PixelGrabber for (int x=0; x<width; x++) { for (int y=0; y<height; y++) { result.setRGB(image1[width*y+x] ^ image2[width*y+x]); } }
- 04-08-2009, 05:37 AM #7
Senior Member
- Join Date
- Jan 2009
- Posts
- 671
- Rep Power
- 5
Unless the two images are extremely similar...with no differences in scale, shift, or rotation, a difference approach will not buy you anything. I recommend converting them to jpeg at the lowest quality factor you are willing to live with.
The javax.imagio package contains what you need to do that.
- 04-08-2009, 06:48 PM #8
Similar Threads
-
what is the difference
By ron87 in forum New To JavaReplies: 5Last Post: 01-04-2011, 04:31 PM -
What is the difference between
By arnab321 in forum New To JavaReplies: 2Last Post: 01-19-2009, 04:49 AM -
what is the difference between jsp and jsf?
By makpandian in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 12-31-2008, 05:55 PM -
difference
By nishant in forum New To JavaReplies: 2Last Post: 09-17-2008, 06:04 PM -
Difference between ASP and JSP
By barney in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 08-07-2007, 07:15 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks