Image processing 存储为numpy的图像中的XY坐标?

Image processing 存储为numpy的图像中的XY坐标?,image-processing,numpy,matplotlib,scikit-learn,Image Processing,Numpy,Matplotlib,Scikit Learn,我有一个96x96像素的numpy阵列,这是一个灰度图像。如何找到并绘制此图像中最大像素强度的x,y坐标 图像=(96,96) 看起来很简单,但我可以找到任何代码片段。 请您提供帮助:)使用argmax功能,结合获取行和列索引: >>> import numpy as np >>> a = np.random.rand(96,96) >>> rowind, colind = np.unravel_index(a.argmax(), a.sha

我有一个96x96像素的numpy阵列,这是一个灰度图像。如何找到并绘制此图像中最大像素强度的x,y坐标

图像=(96,96)

看起来很简单,但我可以找到任何代码片段。
请您提供帮助:)

使用
argmax
功能,结合获取行和列索引:

>>> import numpy as np
>>> a = np.random.rand(96,96)
>>> rowind, colind = np.unravel_index(a.argmax(), a.shape)
就绘图而言,如果您只想使用布尔掩码精确定位最大值,则可以这样做:

>>> import matplotlib.pyplot as plt
>>> plt.imshow(a==a.max())
<matplotlib.image.AxesImage object at 0x3b1eed0>
>>> plt.show()
>>将matplotlib.pyplot作为plt导入
>>>plt.imshow(a==a.max())
>>>plt.show()

在这种情况下,您甚至不需要索引。

但这仍然不能解释如何找到具有最大发生值的所有索引。我该如何循环?@pbu,听起来你好像在试图找到几个峰,而不是一个(正如我从你的问题中所理解的)。那样的话,你应该看看。其中一个答案还链接到。