Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Segmenting overlapping thick lines on a binary image

I do have a binary image as shown below after applying various preprocessing and detection pipelines onto original image.

Intersecting Runways

As seen in the picture there are actually 2 runways (tarmacs) for planes which are crossing each other on an intersection region. What I need is to split both runways and return their contours. I've checked opencv functions regarding contour features but had no luck. cv2.fitLine seems ok but it only works if there is only a single line in the contour. Resulting image when the masks are applied should be looking like this: enter image description here

like image 600
colt.exe Avatar asked Oct 15 '25 17:10

colt.exe


1 Answers

Here's a possible approach, just done in Terminal with ImageMagick, but you should be able to do pretty much the same in Python with Wand or with scikit-image and the medial_axis.

First, skeletonise the image:

magick runways.png -threshold 50% -morphology Thinning:-1 Skeleton skeleton.png

enter image description here

Then run a "Hough Line Detection" looking for lines longer than 130 pixels and ask for the results in a tabular form:

magick skeleton.png -hough-lines 9x9+130 mvg:-

Output

# Hough line transform: 9x9+130
viewbox 0 0 464 589
# x1,y1 x2,y2 # count angle distance
line 297.15,0 286.869,589  # 255 1 476
line 0,591.173 464,333.973  # 189 61 563

That means it has detected 2 lines:

  • a line from coordinates 297,0 to coordinates 286,589, with a length=255 pixels at 1 degree to the vertical
  • a line from coordinates 0,591 to coordinates 464,333, with a length=189 pixels at 61 degrees to the vertical

Just to illustrate, I'll draw the first in red and the second in green:

magick runways.png                       \
   -fill red  -draw "line 297,0 286,589" \
   -fill lime -draw "line 0,591 464,333" result.png

enter image description here

Keywords: Python, image processing, skeleton, skeletonise, thinning, runway, runways, intersection, Hough Line Detection.

like image 186
Mark Setchell Avatar answered Oct 17 '25 10:10

Mark Setchell