Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Morphology transformation to achieve rectangular shape.

Hello,

I wonder: is it possible to modify this input image:

image description

to obtain this output image:

image description

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.