Find tunnel 'center line'?

前端 未结 3 1172
轻奢々
轻奢々 2020-12-23 23:40

I have some map files consisting of \'polylines\' (each line is just a list of vertices) representing tunnels, and I want to try and find the tunnel \'center line\' (shown,

3条回答
  •  Happy的楠姐
    2020-12-24 00:22

    Well in Python using package skimage it is an easy task as follows.

    import pylab as pl
    from skimage import morphology as mp
    
    tun = 1-pl.imread('tunnel.png')[...,0]        #your tunnel image
    skl = mp.medial_axis(tun)                     #skeleton
    
    pl.subplot(121)
    pl.imshow(tun,cmap=pl.cm.gray)
    pl.subplot(122)
    pl.imshow(skl,cmap=pl.cm.gray)
    pl.show()
    

    enter image description here

提交回复
热议问题