我有一组细胞,
下面的图像中的示例

我一直试图使用区域道具或任何其他工具来计算具有相同第一个索引的邻居的数量。
例如,下面有5个蓝色圈的细胞,它们是相邻的,具有第1指数=1,因此,它们的邻域应该都是5,与黑细胞相似。

有人知道怎么算这个吗?
谢谢。
发布于 2016-04-07 14:37:32
您可能只想从每个数组中提取第一个索引,创建一个矩阵(类似于标签矩阵),然后对其使用regionprops。
%// Extracts the first value of each cell
firstValue = cellfun(@(x)x(1), cellArray);
%// Computes region properties using this matrix as a label matrix
result = regionprops(firstValue, property_to_compute);然后,可以根据需要将结果应用到整个单元格数组中。
或者,您可以循环各种第一个索引值,并使用bwconncomp计算连接的组件。
uniqueVals = unique(firstValue);
for k = 1:numel(uniqueVals)
CC(k) = bwconncomp(firstValue == uniqueVals(k));
endhttps://stackoverflow.com/questions/36479375
复制相似问题