为了账号安全,请及时绑定邮箱和手机立即绑定

Networkx 中的“计数”边缘属性是什么?

Networkx 中的“计数”边缘属性是什么?

温温酱 2021-06-04 18:46:42
我不明白什么是由下面的函数计算出的区域邻接图的“计数”属性:skimage.future.graph.rag_boundary()。解释了“重量”属性,但没有解释“计数”属性。即使在阅读源代码时,我也不明白它是什么。有人能帮我吗 ?谢谢这是来源:def rag_boundary(labels, edge_map, connectivity=2):    """ Comouter RAG based on region boundaries    Given an image's initial segmentation and its edge map this method    constructs the corresponding Region Adjacency Graph (RAG). Each node in the    RAG represents a set of pixels within the image with the same label in    `labels`. The weight between two adjacent regions is the average value    in `edge_map` along their boundary.    labels : ndarray        The labelled image.    edge_map : ndarray        This should have the same shape as that of `labels`. For all pixels        along the boundary between 2 adjacent regions, the average value of the        corresponding pixels in `edge_map` is the edge weight between them.    connectivity : int, optional        Pixels with a squared distance less than `connectivity` from each other        are considered adjacent. It can range from 1 to `labels.ndim`. Its        behavior is the same as `connectivity` parameter in        `scipy.ndimage.filters.generate_binary_structure`.    Examples    --------    >>> from skimage import data, segmentation, filters, color    >>> from skimage.future import graph    >>> img = data.chelsea()    >>> labels = segmentation.slic(img)    >>> edge_map = filters.sobel(color.rgb2gray(img))    >>> rag = graph.rag_boundary(labels, edge_map)    """    conn = ndi.generate_binary_structure(labels.ndim, connectivity)    eroded = ndi.grey_erosion(labels, footprint=conn)    dilated = ndi.grey_dilation(labels, footprint=conn)    boundaries0 = (eroded != labels)    boundaries1 = (dilated != labels)    labels_small = np.concatenate((eroded[boundaries0], labels[boundaries1]))    labels_large = np.concatenate((labels[boundaries0], dilated[boundaries1]))    n = np.max(labels_large) + 1
查看完整描述

1 回答

?
森栏

TA贡献1810条经验 获得超5个赞

权重矩阵对应于区域之间边界处像素值的平均值。计数矩阵对应于沿这些边界的像素数。因此,rag[i][j]['count']包含沿区域边界的像素数ij

代码使用了一些花哨的SciPy 稀疏矩阵技巧来提高效率。我(谦虚地;)推荐 Elegant SciPy 的第 5 章(可在http://elegant-scipy.org免费在线获取)以了解有关这些格式的更多信息。


查看完整回答
反对 回复 2021-06-09
  • 1 回答
  • 0 关注
  • 125 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号