python-opencv颜色提取分割方法
作者:Deep_IT 时间:2022-01-22 06:26:23
1.用于简单的对象检测、跟踪
2.简单前背景分割
#encoding:utf-8
#黄色检测
import numpy as np
import argparse
import cv2
image = cv2.imread('huang.png')
color = [
([0, 70, 70], [100, 255, 255])#黄色范围~这个是我自己试验的范围,可根据实际情况自行调整~注意:数值按[b,g,r]排布
]
#如果color中定义了几种颜色区间,都可以分割出来
for (lower, upper) in color:
# 创建NumPy数组
lower = np.array(lower, dtype = "uint8")#颜色下限
upper = np.array(upper, dtype = "uint8")#颜色上限
# 根据阈值找到对应颜色
mask = cv2.inRange(image, lower, upper)
output = cv2.bitwise_and(image, image, mask = mask)
# 展示图片
cv2.imshow("images", np.hstack([image, output]))
cv2.waitKey(0)
来源:https://blog.csdn.net/wang4959520/article/details/50843539
标签:python,opencv,颜色,分割
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
基于python计算滚动方差(标准差)talib和pd.rolling函数差异详解
2023-04-09 17:28:45
![](https://img.aspxhome.com/file/2023/8/83958_0s.jpg)
解决django无法访问本地static文件(js,css,img)网页里js,cs都加载不了
2023-06-13 19:13:36
![](https://img.aspxhome.com/file/2023/7/59637_0s.jpg)
Python中的__new__与__init__魔术方法理解笔记
2021-12-18 14:29:26
好友列表利用率越高,社区越失败
2008-04-10 12:22:00
9种使用Chrome Firefox 自带调试工具调试javascript技巧
2023-07-19 01:03:48
![](https://img.aspxhome.com/file/2023/5/55895_0s.jpg)
JavaScript 图片变换效果(ie only)
2010-01-20 12:40:00
![](https://img.aspxhome.com/file/UploadPic/20101/20/2010120125735780s.gif)
pygame游戏之旅 调用按钮实现游戏开始功能
2023-04-19 06:36:44
![](https://img.aspxhome.com/file/2023/2/87752_0s.jpg)
python Matplotlib绘图直线,折线,曲线
2023-01-12 13:44:09
![](https://img.aspxhome.com/file/2023/3/79433_0s.png)
如何用SA-FileUp上传一个单纯的HTML文件?
2010-05-18 18:29:00
Python实现为图像添加下雪特效
2021-07-10 11:28:45
![](https://img.aspxhome.com/file/2023/9/97369_0s.gif)
用 SA FileUp 上传多文件
2008-07-04 13:44:00
python之PyMongo使用总结
2023-03-11 03:17:48
Python Cloudinary实现图像和视频上传详解
2022-03-13 05:21:13
![](https://img.aspxhome.com/file/2023/2/88882_0s.png)
Python中str.format()详解
2023-01-12 13:26:47
php生成静态页面并实现预览功能
2023-11-15 08:37:11
![](https://img.aspxhome.com/file/2023/3/55693_0s.jpg)
python3实现用turtle模块画一棵随机樱花树
2023-11-30 06:04:07
![](https://img.aspxhome.com/file/2023/9/78789_0s.jpg)
python中的正则表达式,贪婪匹配与非贪婪匹配方式
2023-04-04 18:37:36
编写SQL Server的扩展存储过程实例
2009-01-20 15:45:00
Python脚本在Appium库上对移动应用实现自动化测试
2021-12-27 12:43:24
Python基础知识学习之类的继承
2022-09-02 15:41:05