• Stars
    star
    199
  • Rank 196,105 (Top 4 %)
  • Language
    Python
  • License
    BSD 3-Clause "New...
  • Created over 7 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

build net work from skeleton image (2D-3D)

Skeleton Network

build net work from nd skeleton image

graph = sknw.build_sknw(ske, multi=False, iso=True, ring=True, full=True)

ske: should be a nd skeleton image

multi: if True,a multigraph is retured, which allows more than one edge between two nodes and self-self edge.

iso: if True, return one-pixel node

ring: if True, return ring without any branch (and insert a self-connected node in the ring)

full: if True, every edge start from the node's centroid. else touch the node block but not from the centroid.

return: is a networkx Graph object

image

graph detail:

graph.nodes[id]['pts'] : Numpy(x, n), coordinates of nodes points

graph.nodes[id]['o']: Numpy(n), centroid of the node

graph.edge(id1, id2)['pts']: Numpy(x, n), sequence of the edge point

graph.edge(id1, id2)['weight']: float, length of this edge

if it's a multigraph, you must add a index after two node id to get the edge, like: graph.edge(id1, id2)[0].

Build Graph:

build Graph by Skeleton, then plot as a vector Graph in matplotlib.

from skimage.morphology import skeletonize
from skimage import data
import sknw

# open and skeletonize
img = data.horse()
ske = skeletonize(~img).astype(np.uint16)

# build graph from skeleton
graph = sknw.build_sknw(ske)

# draw image
plt.imshow(img, cmap='gray')

# draw edges by pts
for (s,e) in graph.edges():
    ps = graph[s][e]['pts']
    plt.plot(ps[:,1], ps[:,0], 'green')
    
# draw node by o
nodes = graph.nodes()
ps = np.array([nodes[i]['o'] for i in nodes])
plt.plot(ps[:,1], ps[:,0], 'r.')

# title and show
plt.title('Build Graph')
plt.show()

Find Path

then you can use networkx do what you want

3D Skeleton

sknw can works on nd image, this is a 3d demo by mayavi

About ImagePy

https://github.com/Image-Py/imagepy

ImagePy is my opensource image processihng framework. It is the ImageJ of Python, you can wrap any numpy based function esaily. And sknw is a sub module of ImagePy. You can use sknw without any code.

More Repositories

1

imagepy

Image process framework based on plugin like imagej, it is esay to glue with scipy.ndimage, scikit-image, opencv, simpleitk, mayavi...and any libraries based on numpy
Python
1,267
star
2

planer

Powerful Light Artificial NEuRon inference framework for CNN
Python
61
star
3

myvi

myvi is a simple and light mayavi, m(a)y(a)vi.
Python
42
star
4

geonumpy

treat gis data with numpy
Python
22
star
5

opencv-plgs

plugins based on opencv for ImagePy
Python
15
star
6

demoplugin

some demo to show how to write imagepy plugin
Python
12
star
7

sciwx

split widgets from imagepy to make it could be used independently.
Python
9
star
8

itk-plgs

imagepy plugins with simpleitk
Python
9
star
9

cellpose-lighting

reimplement cellpose without gui
Python
8
star
10

cellpose-plgs

cellpose plugin for imagepy
Python
7
star
11

xlreport

use dictionary fill excel template and generate report
Python
6
star
12

seaice

some imagepy plugins for seaice rs image processing
Python
6
star
13

cellpose2msk

transform cellpose hot image to label mask
Python
4
star
14

planer-zoo

toolbox of planer
Python
4
star
15

cellpose-planer

cellpose on planer framework, light and fast!
Python
4
star
16

IBook

ImagePy's plugins to show some image processing method, which is friendly to beginner
Python
3
star
17

visplt

build a matplotlib like interface for vispy
3
star
18

skimg-plgs

A plugins system for imagepy based on scikit-image, a convenient toolset and a good tutorial for studying scikit-image.
Python
3
star
19

measure3d

measure adjustment
Python
2
star
20

sciwx_camera

a camera panel for sciwx, can work with imagepy
Python
2
star
21

cell-morphometric

Quantitative morphometric analysis of hepatocellular carcinoma
Python
2
star
22

chineseorg

这个项目用于建设中文社区
2
star
23

npimage

scipy.ndimage implements in pure numpy (for scipy loaded slowly in pyodide)
Python
2
star
24

npdf

make a pandas like interface with pure numpy
1
star
25

gistool

Python
1
star