0 votes
1 view
in Machine Learning by (17.3k points)

I have an image with horizontal and vertical lines. In fact, this image is the BBC website converted to horizontal and vertical lines. My problem is that I want to be able to find all the rectangles in the image. I want to write a computer program to find all the rectangles. Does anyone know how to do this or suggest ideas on how to get started? This task is easy for me as a person to find the visual rectangles, but I am not sure how to describe it as a program.

Image is the BBC website here http://www.bbc.co.uk/

I wrote the code which converts the BBC website image to the horizontal and vertical line, the problem is these lines do not completely meet at the corners and sometimes they do not completely form a rectangle. Thanks!

1 Answer

0 votes
by (33.2k points)

Nowadays, there are many libraries to solve your problem. OpenCV (image processing and computer vision library written in c) has implementation for Hough transform (the simple hough transform find lines in an image, while the generalized one finds more complex objects) so that could be a good start. This transformation is also used to find faces in an image and reflect them with a rectangle or square. For the rectangles which do have closed corners, there are also corner detectors such as cornerHarris which can help.

I ran the hough lines demo provided with OpenCV and here's the result on the image you gave (detected lines marked in red): 


In the above image, you can see that wherever the closed rectangular patterns were observed, the algorithm has drawn some specific rectangular shapes there.

Hope this answer helps.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !