I know this question is some days old, but in case someone comes across, I can drop a suggestion on how to solve this:
It indeed takes some computer vision or image processing tasks, but I would do it like this:
- At first you could apply some morphological operations (like opening or closing) in order to reduce the spurious black pixels in the background. You have to play around with different combinations of such operations to get what you want.
- Then you could compute connected components (= connected regions of pixels belonging together), which basically gives you labels for all pixel regions.
- Then you can filter those connected components for the 2 biggest ones (= the ones with the most pixels in it), which will give you the two hand regions only.
- Now you can decide - maybe using the x/y-coordinates of the center of each region - which region you want to mask out, e.g. by filling it with the gray-value from the background pixels.
I hope this helps and gives some clues on how to do it.