When an image is shot by the webcam, the first processing is having a black and white picture where the white must represents the spots of the scene. That's why the actor must be worn in black or in dark colours and the spots must be white.
The hypothesis for this part of Image Processing is that the grayscale image have a threshold from which above only the spots appear. The problem to determine the threshold is that for practical purpose, it is not the same for every webcam, and it also depend of the conditions of the shot.
The aim to make an automatic system leads us to try other sorts of image processing.
To equalize the histogram :
In our problematic, equalizing the histogram permits to have, in the processed image, the spots in the high white tonal values. And that for every camera and shot conditions. The problem is that depending on the number of pixel the spots use, the spot could be in several tonal values. And if we choose to keep too many components to filter the spot, we easily get some patches that are not spots. Since the number of pixel that the spot uses could change because of occlusions, patches could often appear.
The transformation Erode/Dilate, applied to remove little patches are not enough to remove them that appear during occlusions.
The final choice is to let the user to settle the threshold of the grayscale image, and possibly the right to erode to remove some trash pixels ( but with sane mean, because this processing is expensive )