I have a binary image with boundaries, like this one:
I want to find a binary image that contains the filled regions corresponding to those boundaries. I did it manually on Paint, and the result should look like this:
I've been looking for a solution, and I just found this post but the solution provided just works if the image consists mainly of a background, which may not be necessarily my case. I tried using scipy.ndimage.binary_fill_holes but it does not work with regions that touch the boundary:
Is there some other way to make this work for all regions (including those that touch the boundary)?
EDIT: I don't mind which one is the filled region and which one is not. Namely, if the values are inverted, it is fine too. I just need a binary division, it doesn't matter which ones are filled and which ones are not, as long as the boundaries correctly separate the two kinds.



