Hello,
I wonder: is it possible to modify this input image:
to obtain this output image:
using only morphology transformation? I know, I can use contour detection, make rectangle out of this contour and then paint it over the image but I don't want to analyse contours. I would like to somehow dilate the image so the rectanle would close itself but it would retain holes in it at the same time. It does not have to be perfect, holes can be smaller but I need to have these holes inside.
I've tried a lot of erode /dilate operations with custom kernals but failed to achieve desired result. Could somone help? Thank you.