views:

51

answers:

1
+1  Q: 

pixel difference

i m a beginner in java programming. i have to submit project of server- client and stuck in pixel comparision .acc to code it accepts buffered image and compares pixel how to store pixel difference in 2nd image itself and return it?? do help with code?

+2  A: 

Take a look at BufferedImage's getRGB(int x, int y) method. This will provide an approximate RGB value for the given (x, y) location as an int, which can then be compared to the corresponding location in the other image.

If you wish to perform a more detailed comparison you'll need to iterate over each image band separately, comparing the samples for that band with the corresponding band for the other image. (For example, an RGBA encoded image has four individual bands to compare, whereas a greyscale image has just one.)

Obviously you could start by comparing the image dimensions to ensure they are equal before proceding to the more detailed comparison.

Also, you should not expect people to paste detailed code solutions; That's not the way Stack Overflow works - People will be far more willing to help with specific problems so you should try coding the solution and post a code snippet if you get stuck.

Adamski