Hey, im trying to convert the below image into skeleton using opencv.

By using
----------------------------------------
size = np.size(crop)
skel = np.zeros(crop.shape,np.uint8)
element = cv2.getStructuringElement(cv2.MORPH_CROSS,(3,3))
done = False
while( not done):
eroded = cv2.erode(crop,element)
temp = cv2.dilate(eroded,element)
temp = cv2.subtract(crop,temp)
skel = cv2.bitwise_or(skel,temp)
crop = eroded.copy()
zeros = size - cv2.countNonZero(crop)
if zeros==size:
done = True
------------------------------------------------------------------
And i got this

There are some noise and the line are not connected properly. any help pls? Thanks!
↧