Enlarging binary mask

asked 2018-11-12 12:20:26 -0500

karollo gravatar image

From my image, I created a binary mask marking some objects (up to three-four objects on one image). Let's say, that those marked objects on my mask have a total surface area of X.

Now I want to enlarge their contours so that the space that will remain (black area) will have a surface area of X. If they take more than 50% of the image then I want to leave it unchanged.

I could use dilatation in a loop and check if the size is appropriate in every iteration, but I am looking for some more elegant way :)

edit retag flag offensive close merge delete