How to detect almost straight lines in an image using MATLAB? Hough Transform not able to detect the lines properly, as lines are not exactly smooth. And, is there any way to detect all the rectangles in the image or thick lines (assume same color rectangle as a thick line)?? Here is the image enter image description here

有帮助吗?

解决方案

Apply canny edge detector to the image and do a labeling and you'll detect most of the rectangles.

rgb : the image

edges = edge(rgb2gray(rgb), 'canny');

labels = label2rgb(bwlabel(edges, 8));

figure, imshow(edges)

figure, imshow(labels)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top