CV2.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:reconstruction 作者: microelly2 项目源码 文件源码
def execute_Skeleton(proxy,obj):

    from skimage.morphology import medial_axis

    threshold=0.1*obj.threshold

    try: 
        img2=obj.sourceObject.Proxy.img
        img=img2.copy()
    except: 
        sayexc()
        img=cv2.imread(__dir__+'/icons/freek.png')

    data = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

    # Compute the medial axis (skeleton) and the distance transform
    skel, distance = medial_axis(data, return_distance=True)

    # Distance to the background for pixels of the skeleton
    dist_on_skel = distance * skel

    # entferne ganz duenne linien
    dist_on_skelw =(dist_on_skel >= threshold)* distance

    say("size of the image ...")
    say(dist_on_skelw.shape)
#   skel = np.array(dist_on_skelw,np.uint8) 
    skel = np.array(dist_on_skelw *255/np.max(dist_on_skelw),np.uint8) 
    obj.Proxy.img=cv2.cvtColor(skel*100, cv2.COLOR_GRAY2BGR)
    obj.Proxy.dist_on_skel=dist_on_skelw
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号