Skip to content

Missing single-edge paths between two junctions  #147

Description

@ssavary

Some paths consisting of only 2 nodes are missing in Skeleton.paths_list(), depending on the order the nodes ares visited.

Here is a simple script that shows the problem, with a simple (10,10) skeleton and its rotated version. The path list for figure 1 is

[[1, 2, 3],
[3, 4, 5, 6, 7, 8, 9],
[3, 10, 11],
[11, 12, 13, 14],
[11, 17],
[15, 16, 17],
[17, 18, 19, 20, 21]]

and the path list for the graph of figure 2 is:

[[1, 3, 5],
[2, 4, 8],
[5, 6, 7],
[5, 13, 15, 17, 19, 20, 21],
[7, 14, 16, 18],
[8, 9, 10, 11, 12]]

In the first figure, path (11,17) is found, but the equivalent path (7,8) was not found in figure 2.
Figure_1
Figure_2

Here is the script that was used to generate this example.

import numpy as np
import skimage
from skan import csr, draw
import networkx as nx
import matplotlib.pyplot as plt

I = np.zeros((10, 10))

rr, cc = skimage.draw.line(4,0,4,2)
I[rr, cc] = 1
rr, cc = skimage.draw.line(3,2,3,5)
I[rr, cc] = 1
rr, cc = skimage.draw.line(1,2,8,2)
I[rr, cc] = 1
rr, cc = skimage.draw.line(1,0,1,8)
I[rr, cc] = 1

skeleton1 = csr.Skeleton(I)
paths1 = skeleton1.paths_list()

# skeleton of the transposed image
skeleton2 = csr.Skeleton(I.T)
paths2 = skeleton2.paths_list()
   
plt.ion()
draw.overlay_skeleton_networkx(skeleton1.graph, skeleton1.coordinates)
draw.overlay_skeleton_networkx(skeleton2.graph, skeleton2.coordinates)

print(paths1)
print(paths2)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions