Removing everything in one image from another image

Say I have the following two images:

before.jpg:

after.jpg:

I would like to be able to remove everything in before.jpg from after.jpg but I don’t want the things in before.jpg being added to after.jpg. I want the result to look like this:

result

Any idea how I can do this?

“after or not before”

translate into whatever expressions you require. OpenCV has bitwise_and/bitwise_or/bitwise_not functions.

ordinarily, background is black, not white, requiring the expression “after and not before”.