使用 opencv / Numpy 使用 python 查找彩色图像中的白色像素

Cha*_* L. 1 python opencv numpy

我有一个使用 opencv 加载的图像,我想找到白色的像素。

input_img = [[[255,255,255], [0,127,255]],
             [[255,255,255], [255,127,255]]]
Run Code Online (Sandbox Code Playgroud)

应该返回

white = [[1, 0],
         [1, 0]]
Run Code Online (Sandbox Code Playgroud)

有没有一种方法可以在不重塑或不使用昂贵的 for 循环的情况下做到这一点?使用类似 numpy.where 的东西?

YXD*_*YXD 5

怎么样

(input_img == 255).all(axis=2)
Run Code Online (Sandbox Code Playgroud)