skel = np.uint8(skel)
kernel = np.uint8([[1, 1, 1], [1, 10, 1], [1, 1, 1]])
src_depth = -1
filtered = cv2.filter2D(skel, src_depth, kernel)
out = np.zeros_like(skel)
out[np.where(filtered == 11)] = 1
return out
How can I find endpoints of binary skeleton image in OpenCV?