如何通过三个堆叠的numpy数组(代表图像)取最大值来得到交集面积?

How to get the maximum value of three stacked numpy arrays (representing images) to get the intersection area?

我在三个 numpy 数组中有三个图像 a,c,s。这些值介于 [0,0.99](概率)之间。下图为图片竖排。

我通过这个命令x=np.dstack([a,c,s])把它们堆叠起来,形状变成了(256, 256, 3),得到如下图:

我想得到三个堆叠数组中的最大值,图像的最大交集区域,例如对于每个点,我们有三个值:

print x[200,100,:]
out: [0.99662614 0.98577976 0.99949038]

获得 argmax 后,我得到以下输出:

maxIndex= np.argmax(x, axis=2)
print np.shape(maxIndex)
plt.imshow(maxIndex)
plt.show()

这不是我想要的。你能指导我如何以可以获得三个值的最大交集面积的方式获得三个值的最大值吗?

如果我理解正确的话,你忘了使用 argmax 索引来实际获得沿 axis=2:

的最大值
rr, cc = np.meshgrid(np.arange(x.shape[0]),
                     np.arange(x.shape[1]),
                     indexing='ij',
                     sparse=True)
x_max = x[rr, cc, maxIndex]