问题描述
我有一个包含 1 和 0 的数组,其中 0 表示最初来自图像的背景和 1 信息。我首先找出哪些 1 属于一起(因此是沿着它们理论像素边的直接邻居或在它们的角落对角接触)。所有“邻居”都被枚举,因此我可以进一步获得每个“邻居”/标签的总和、平均值等。
但是,这些值应该代表像素值,我想找出它们的实际长度,因为简单地总结像素会低估它们的实际长度,我需要找到另一种计算方法。我调查了这个,但找不到我必须计算得到实际长度的确切内容。 (我不是在谈论将像素值标准化为它们的实际尺寸。)
import numpy as np
import skimage
from skimage.measure import label
from scipy.ndimage.measurements import label
# example array where I need to find groups of neighbors
inters_array= ([[0,1,0],[0,0]])
# structure array to deterimine neighbors in 8-dimensions
struc = np.ones((3,3),dtype=int)
# skimage function to get label objects,i.e. groups of neighbors
neighbors,ncomponents = label(inters_array,structure=struc)
""" where in theory it detects the groups of neighbors and gives them the same number
as long as they are neighbors like so:
neighbors = ([[0,2,0]]) """
# measure.regionprops() will give me an object
# as extraproperties I can add custom functions
regionpros = skimage.measure.regionprops(neighbors,intensity_image=None,cache=True,extra_properties=None)
# like the perimeter of each object
regionpros_peri = regionpros[0].perimeter
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)