'Watershed algorithm: Various colors on gray background

I am trying to figure out the most effective way of doing image segmentation without using deep learning with a steep learning curve. In my efforts I have come across the watershed algorithm which seems promising, but as far as I can understand it requires a black background to detect the edges.

This is my first problem because I have a gray background on my images(static shot from a top down camera), which can be solved by recoloring the background to something darker.

My second problem is that I want to detect various objects, some of them being black.

These problems messes up my dreams of using the watershed algorithm for any kind of automatic image segmentation, because each image would need to consider the color composition of the objects I want to segment.

Does anyone know of a solution to this or a method similar to the watershed algorithm?

Edit: Reference image

Random objects to segment

Best regards Martin



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source