1

I am trying to retrive the edges of an basket ball court. I was successful in creating a mask by using the histogram of the image. I would like to know what is the best approach to extract the straight lines from the image mask.

Image mask

I would like to extract the following edges marked in red as lines from the mask

enter image description here

Could some one tell me what is the best method or algorithm to use. FYI, I tried houghlines but I get line segments that are very small.

enter image description here

Thank you

Bow
  • 445
  • 1
  • 6
  • 17
  • 1
    LineSegmentDetector is a very robust algorithm for both, mask images and general images. For masks you might also see good results with contour extraction and houghLines, or contour approximation, or approxPolyDp – Micka Sep 03 '22 at 13:28
  • I tried lineSegmentDetector as well, but I am still getting smaller segments instead of one big segment that scales the edge of the court completely. – Bow Sep 03 '22 at 13:30
  • Sure, since there are no big segments you will have to join them afterwards, by testing which segments might belong to the same bigger line. For example with a RANSAC test for inliers and outliers. – Micka Sep 03 '22 at 13:31
  • I would try running a few [dialtions followed by erosions](https://docs.opencv.org/3.4/db/df6/tutorial_erosion_dilatation.html) this will fill in gaps. Then I'd try contours or Houghlines. – DrBwts Sep 03 '22 at 13:50

0 Answers0