def image_summary(skeleton, *, spacing=1):
"""Compute some summary statistics for an image.
Parameters
----------
skeleton : array, shape (M, N)
The input image.
Other Parameters
----------------
spacing : float or array of float, shape (`skeleton.ndim`,)
The resolution along each axis of `skeleton`.
Returns
-------
stats : pandas.DataFrame
Selected statistics about the image.
"""
stats = pd.DataFrame()
stats['scale'] = [spacing]
g, coords, degimg = csr.skeleton_to_csgraph(skeleton, spacing=spacing)
degrees = np.diff(g.indptr)
num_junctions = np.sum(degrees > 2)
stats['number of junctions'] = num_junctions
pixel_area = (spacing ** skeleton.ndim if np.isscalar(spacing) else
np.prod(spacing))
stats['area'] = np.prod(skeleton.shape) * pixel_area
stats['junctions per unit area'] = (stats['number of junctions'] /
stats['area'])
sizes = mesh_sizes(skeleton)
stats['average mesh area'] = np.mean(sizes)
stats['median mesh area'] = np.median(sizes)
stats['mesh area standard deviation'] = np.std(sizes)
structure = np.ones((3,) * skeleton.ndim)
stats['number of disjoint skeletons'] = ndi.label(skeleton, structure)[1]
return stats
评论列表
文章目录