【发布时间】:2019-02-16 20:45:56
【问题描述】:
我有 2 个相同尺寸的 3D 灰度图像。
第一张图像 (img) 是 3D 体积的原始数据(使用显微镜获得)并包含各种细胞。 Example slice of raw 3d image
第二张图像 (imglab) 是原始图像的蒙版版本,其中每个识别的单元格都填充了一个唯一的值(即单元格 1 = 全为 1,单元格 2 = 全为 2)。所有非单元区域都是零。 Example slice of masked 3d image
我现在正试图从与标记的掩码数组对应的原始数据中找到每个单元格最大值的坐标。
目前,我有一个效率极低的循环。我怀疑有一种方法可以使用单个 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:scikit-image.org/docs/dev/api/…
标签: python numpy image-processing