使用python使用opencv/numpy查找彩色图像中的白色像素 [英] Using opencv / Numpy to find white pixels in a color image using python

查看:316
本文介绍了使用python使用opencv/numpy查找彩色图像中的白色像素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have an image I loaded using opencv, that I would like to find pixels that are white.

input_img = [[[255,255,255], [0,127,255]],
             [[255,255,255], [255,127,255]]]

应该返回

white = [[1, 0],
         [1, 0]]

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

Is there a way to do this without reshaping or without an expensive for loop? Using something like numpy.where?

推荐答案

如何

(input_img == 255).all(axis=2)

这篇关于使用python使用opencv/numpy查找彩色图像中的白色像素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆