我有两个相同维度的3D灰度图像。
第一张图像(img
)是三维体积的原始数据(使用显微镜获得),包含各种细胞。原始3D图像示例切片
第二张图像(imglab
)是原始图像的掩膜版本,其中每个已识别的细胞都被填充了一个单独的唯一值(即细胞1 = 全部为1,细胞2 = 全部为2)。所有非细胞区域均为零。掩膜3D图像示例切片
我现在正在尝试找到与标记掩码数组对应的原始数据中每个细胞的最大值的坐标。
目前,我有一个极其低效的循环。我怀疑有一种方法可以使用单个np.where
调用设置多个条件,但我无法弄清楚如何做到这一点。当前的for
循环方法如下:
coordinates = []
for i in range(1, int(imglab.max())): # Number of cells = max value of label image
max_val = np.max(img[imglab == i])
max_coord = np.where((img == max_val) & (imglab == i))
coordinates.append(max_coord)
regionprops
:http://scikit-image.org/docs/dev/api/skimage.measure.html#skimage.measure.regionprops - Cris Luengo