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
评论列表
文章目录