1

I am looking for an efficient way to compare 2 images and get the changed areas as a result.

My current attempt has the following steps:

  1. Compare each horizontal line and keep the changed line index in a list
  2. Compare each vertical line and keep the changed line index in a list
  3. Iterate over each changed horizontal line, finding each start and end point of the height while iterating over the vertical changes lines finding the width of the area.

This method has its flaws and seems not really fast.

One of the flaws is that if there are 2 changed areas on a diagonal, this method detects 4 changed areas. however this small abnormality isnt an issue for my use case.

Are there any more efficient methods? I was thinking, how does VNC or TeamViewer detect screen changes?

The idea is that there is a base image. A user draws (not in application) extra details to it. I want to compare these images and find where the user has drawn extra details.

1
  • "changed areas" is ambiguous. It sounds as if your definition of the term is the problem. There are many ways to store a list of changed areas. Provide more information about why you need this list. – Frank Hileman Dec 15 '16 at 17:49
2

I'd jump onto stack overflow and search in the OpenCV and image processing areas there. I've used opencv to do something similar. You can do an efficient image difference by running an opencv subtraction across two images. You then turn the output of that step into a monocolour image and count the pixels that are above a threshold value (to account for minute variations in the images). Good Luck!

1
  • To take this a step further, once you have the binary image that indicates pixels that have changed, you will need use that image as a mask to obtain the actual pixel values of the edited image. – Dave Nay Dec 16 '16 at 17:50
1

Your description sounds like you are doing some sort of annotation on top of an existing image. Similar to the new features in Microsoft Edge where you can put comments on top of a web page.

The easiest way to do this in your scenario is to capture all of the users drawings to a separate buffer behind the scenes with a transparent background. You then composite the two images for display to the user on screen by first drawing the background image, then draw the user edits on top. Since the edits buffer has a transparent background, the background image will show through.

Using this method, you will not need to separate the user edits, they will already be in their own buffer.

2
  • But the issue with that is that the user draws not in the application. The user edits it with a editor of choice. (MS Paint, GIMP, ...). After that the image gets imported back to the application – eKKiM Dec 16 '16 at 11:08
  • Ahh, well that does complicate things quite a bit. You would definitely be best pursuing a solution along the lines suggested by Monza. I do have to warn you though, image subtraction can get pretty complicated for color images. I will comment on the other solution. – Dave Nay Dec 16 '16 at 14:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.