我试图对下面的特征进行骨架化,以便提取有关1)特征长度的信息2)特征的曲率。我遇到了这个skeletonization approach,它反复侵蚀并侵蚀了图像。下面显示的结果 - 看起来很糟糕。有人可以推荐一种不同的方法来诠释我的功能吗?
以上链接中的示例:
import cv2
import numpy as np
img = cv2.imread('sofsk.png',0)
size = np.size(img)
skel = np.zeros(img.shape,np.uint8)
ret,img = cv2.threshold(img,127,255,0)
element = cv2.getStructuringElement(cv2.MORPH_CROSS,(3,3))
done = False
while( not done):
eroded = cv2.erode(img,element)
temp = cv2.dilate(eroded,element)
temp = cv2.subtract(img,temp)
skel = cv2.bitwise_or(skel,temp)
img = eroded.copy()
zeros = size - cv2.countNonZero(img)
if zeros==size:
done = True
cv2.imshow("skel",skel)
cv2.waitKey(0)
cv2.destroyAllWindows()