Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Merge contours from image

My task is to detect shapes on a whiteboard. So far, I have used blur, morphology, edge canny detection and then the findcontour function. I think that the output looks quite look, but the issue i'm facing is that the contours are not "whole". The below image show the original image with the contours displayed.

image description

What I would like is to somehow merge the contours for each rectangle. and discard the contours for the text. Preferably, I would like something like the below image

image description

When looking around the net, people suggest using more morphology (with morph closed on the image) to get more consistent boxes. But I can't really get it to work. Is there a standardized way to archive the desired output, or should I do some calculations myself to see if I can merge the contours? What would you do from here?

I tried with ApproxPolyDP, but since the contours are not "whole" the area returned is very small.