How to compare two images pixel by pixel and frame new image from the dirty part of image

2.6k Views Asked by At

I am capturing the screen using robot.screenCapture() and frame bufferedImage1. Again I am capturing desktop screen and frame bufferedImage2.

Could please tell me how to compare these 2 images (bufferedImage1 and bufferedImage2) pixel by pixel. If there is any difference, then how to frame the part that is different?

1

There are 1 best solutions below

2
On BEST ANSWER

Here's one way to do it:

  1. Compare the entire images, get the percentage of pixels that differ more than a threshold.
  2. Divide into quarters recursively, down to a certain size, and get the same percentage for each quadrant.
  3. Draw the frame around the quadrants that are a certain amount above the average difference. If you need square sections, use a single quadrant based on size and percent difference. Otherwise, you can combine more than one quadrant with large differences.