您可以使用^{}+^{}。其思想是将图像转换为灰度,然后找到低于某个阈值的所有像素的坐标。注意在灰度中,图像有一个像素值为[0 ... 255]
将此输入图像与threshold_level = 20一起使用
我们把低于这个阈值的所有像素都涂成蓝色
所有像素坐标可以使用np.where()从掩模中确定,并用np.column_stack()堆叠成(x, y)格式。下面是所有低于阈值的像素坐标coords = np.column_stack(np.where(gray < threshold_level))
^{pr2}$
使用threshold_level = 50:
[[ 21 375]
[ 22 375]
[ 23 376]
...
[474 681]
[474 682]
[474 683]]
代码import cv2
import numpy as np
i