Static labels in watershed

No, I don’t have the distance field. Basically I generate the markers using an opening operation of the original map, then apply connectedComponents to identify each relevant section, then finally apply the watershed to cover unknown areas.

After digging a bit I saw that the documentation mentions that the object boundaries are stored as -1:

In the function output, each pixel in markers is set to a value of the “seed” components or to -1 at boundaries between the regions.

However this behavior is a bit annoying since it introduces artifacts. I’d like to clean them from the output.

(It also means I incorrectly identified my initial problem, since what I thought was the background bleeding was actually the region boundary artifacts; however I don’t understand why the background is not bleeding - what prevents the light gray section from filling the black one? why does the algorithm prefer the dark gray one?)