Frame differencing White background.

For a project I am working on, I use frame differencing to separate the object from the background, this works perfectly fine, until I try to put a darker object into the frame.

With darker objects in frame differencing I would like to set the background to white, so the darker object is clearly visible and not almost the same color as the background. Is there a way for me to do something like this?

I tried inverting the image, but in all cases this inverts the placed object in the frame also, making everything white and leaving me with the same problem. After that I tried using a white mask, but couldn’t find where to implement it to get the results I would like to get.

If I am right frame differencing just compares the matrices of the 2 images and thus every part that is the same color, for example 205-205=0 and being a 0 is black? Or is this completely misunderstood? If we could get access to these matrices and convert all the 0’s to 1’s it’s done, but I don’t know if this is possible in Open MV?

I Also looked into “image.b_xor(image[, mask=None])” to possibly combine images to get the same results, but without an example I couldn’t figure out how to properly use this command. 3

Frame differencing just does abs(image1-image2) so, the output of it is always black. Anything that is not black is then a difference. If you invert the difference image then non-differences will be white and anything not white is a difference.

It sounds like you want to be able to pickup a dark object that’s the same color as the image background… Is this correct?

Thanks for your reply,

I understand that frame differencing is just image1-image2, and it is also logical that the resulting background is black after that.
When I invert the difference image it gives me the complete image inverted, and thus the dark object has become white too.

Yes I want to be able to pickup a dark object on a dark background, but this might not work then? (We want to be able to detect white and black objects, so changing the background color to white won’t help) I use the Grayscale because of the global shutter, but it might need to be switched back to normal and we need to start working in RGB and choose a green or blue background for example?

Or is there a way to only invert the (0) real black in an image, for example with a threshold?

You should use histogram equalization. This will increase the image contrast. So, just do .histeq() before the doing frame differencing. This make the black object pop. However, it will also increase the noise. Histeq() has some parameters you can play with too.