median(input, labels=None, index=None)
The function returns a Python list and not a NumPy array, use np.array to convert the list to an array.
A list of region labels that are taken into account for computing the medians. If index is None, the median over all elements where labels is non-zero is returned.
Calculate the median of the values of an array over labeled regions.
from scipy import ndimage
import numpy as np
a = np.array([[1, 2, 0, 1],
[5, 3, 0, 4],
[0, 0, 0, 7],
[9, 3, 0, 0]])
labels, labels_nb = ndimage.label(a)
labels
ndimage.median(a, labels=labels, index=np.arange(1, labels_nb + 1))
ndimage.median(a)
ndimage.median(a, labels=labels)
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them