4

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.

Irtaza
  • 599
  • 10
  • 18
  • Your question is completely unclear. – Julien Aug 08 '16 at 11:33
  • The title implies you are looking for a point. Your question implies you are looking for some lines. Please clarify. – Mark Setchell Aug 08 '16 at 11:50
  • I'm looking for points where the lines meet or (would meet) since some lines may not be completely joined to another line. @MarkSetchell 2 points form a line segment i.e p1 to p2 – Irtaza Aug 08 '16 at 12:18
  • Maybe you could add another image showing the first line you mean in red, the second line you mean in green and the answer you seek in blue so as to clarify things? Don't remove the original image though because folks may want to use an image without annotation to work on. – Mark Setchell Aug 08 '16 at 12:24
  • @MarkSetchell added. ! – Irtaza Aug 08 '16 at 14:50
  • @JulienBernu I have edited it for clarity. if you think its clear now please remove the downvotes.? – Irtaza Aug 09 '16 at 08:03

1 Answers1

2

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

andrew
  • 2,451
  • 1
  • 15
  • 22
  • @andew I have editted the question, can you please take a look at it again. I have defined entire problem now, also mentioned what I've tried. – Irtaza Aug 09 '16 at 08:00
  • 1
    I edited my response, but it is still only a partial answer, good luck – andrew Aug 09 '16 at 19:42