在Numpy中提取二进制图像中0的行和列索引

Extract row and column indexes of 0s in binary image in Numpy

所以,我有一个二值化灰度图像,我想要图像中所有 0(暗像素)的 x、y 点。

image = np.random.rand(30,70)
binary = image > 0.70 #thresholding 
points = np.asarray(np.where(bin == False))
points = points.reshape(-1,2)
pl.imshow(image,cmap='gray')
pl.scatter(p[:,0],p[:,1])
pl.show()

我正在使用 np.where 提取此图像中存在 0 或 False 的所有索引(x,y 坐标),但它不起作用。这是非常奇怪的输出。

不应该是黑色像素上面的蓝点吗?还有为什么蓝点在尺寸(30*70)之外?

看似很简单的问题却出乎意料的结果。

修改变量名称(binarypoints,而不是 binp)后,我看到的唯一问题是你已经完成了 points = points.reshape(-1,2) 没有明显的原因(混淆坐标)并且显示 image 和散射 points 将具有不兼容的方向。像

image = np.random.rand(30,70)
binary = image > 0.70 #thresholding 
points = np.asarray(np.where(binary == False))
pl.imshow(image,cmap='gray')
pl.scatter(points[1],points[0])

应该给