I would like to fill the objects based on their boundaries. I did found something similar has been done already as shown here. But with this I am not able to fill more than one object. For example, my image is
and the output with this code is
As you can see, it can fill only one object and not the top right object. Do you have some suggestions? What could be wrong? what can I try?
Thanks in advance

