jni / skan

Python module to analyse skeleton (thin object) images
https://skeleton-analysis.org
BSD 3-Clause "New" or "Revised" License
118 stars 39 forks source link

How to find endpoints and junction points? #180

Open siddagra opened 2 years ago

siddagra commented 2 years ago

I am having an issue... Whether I use src or dst coords.. image- or otherwise, It often detects junctions as dst instead of the endpoints.

How do I specifically get the correct endpoints and junction points corresponding to those endpoints?

degree functionality also seems to be removed otherwise I could use that to check if a node has a degree higher than 2 as junction.

image

code:

skeleton = cv2.imread("skeletontest.png")[:, :, 1].astype(bool)
pt, degrees = skeleton_to_csgraph(skeleton)
df = summarize(Skeleton(skeleton))
branch1 = df[df['branch-type'] == 1]
endpoints = branch1[["image-coord-dst-0", "image-coord-dst-1"]].values.astype(np.int64)

# plot
# (plotting has to interchange coordinates since the endpoints lists y coordinates first)
for i, pnt in enumerate(endpoints):
    plt.scatter(pnt[1], pnt[0], color="red", s=3)

(plotting has to interchange coordinates since the endpoints lists y coordinates first)