Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find polygon vertices from edge detection images?

1. The problem

Given the images of a house roof, I am trying to find the contours of the roofs. I have labelled data available (as polygon vertices) which I interpolate and create the truth image which is shown below ground truth from annotations

I use canny, hough-lines, LBP features to train an ML model the results look decent. the model output is shown in the middle, and overlay on test image is shown on right.

left original image, middle Model output, right: Output over-layed to original image

2. What I need.

The final output should really be a set of polygons and I need to find the points on which these polygons should be drawn (see the highlighted points in image below). So the output can be set of n line segments. where each line segment is 2 points [(x1,y1),(x2,y2)]

marked image with vertices coded in color

3. What are my thoughts/ideas;

a. Erosion,Dilation,Opening,closing,skeletonize operations

While these operations make the lines in the above image much neater, they don’t help me find the polygon vertices I am looking for.

I'd like to fit (a number of) lines to the white pixels in the image (something like hough lines).

The intersections of these lines would give me the vertices for the polygons I am looking for.

I am wondering if there is a more standard/better way of accomplishing the above.

like image 755
iratzhash Avatar asked Oct 21 '25 22:10

iratzhash


1 Answers

I think HoughLinesP will help you in your goal. It will find line segments and output them in a vector [x1,y1,x2,y2] where (x,y) pairs represent the start and endpoints of line segments.

Each vertex should be near the end of 2 or more line segments. You go through each of the endpoints and count how many times they appear. When you've processed all the points you can eliminate any that have less than 2 occurances. Of course you will need some small threshold for determining a point is unique because the gaps in the lines some psuedocode: dist(point1, point2) < some_delta_threshold

I'm not sure how you would find the polygons at this point, but hopefully this offers some assistance

like image 88
andrew Avatar answered Oct 24 '25 13:10

andrew