当前位置:网站首页>opencv之图像二值化处理
opencv之图像二值化处理
2022-07-31 05:16:00 【xp_fangfei】
opencv二值化操作分为:全局阈值和局部阈值两种。在进行图像二值化之前需要对图片进行灰度处理。
全局阈值
全局阈值分为:手动阈值和自动阈值两种。
手动阈值
opencv函数:
threshold(gray_src, dst, threshold_value, threshold_max,THRESH_BINARY);
//原图,目标图,已知阈值(用于比较的阈值),阈值最大值,阈值类型(threshold()函数支持的对图像取阈值的方法由其确定)
该函数对图像取阈值的方法有5种:
THRESH_BINARY:过门限的值为最大值,其他值为0

THRESH_BINARY_INV:过门限的值为0,其他值为最大值

THRESH_TRUNC:过门限的值为门限值,其他值不变

THRESH_TOZERO:过门限的值不变,其他设置为0

THRESH_TOZERO_INV:过门限的值为0,其他不变

自动阈值
自动阈值分为大津法和三角形算法两种:
- 大津法
opencv函数:
threshold(gray_src,dst,0,255,cv.THRESH_BINARY | cv.THRESH_OTSU)
- 三角形算法
opencv函数:
threshold(gray_src,dst,0,255,cv.THRESH_BINARY | cv.THRESH_TRIANGLE)
局部阈值(自适应阈值)
计算局部阈值中方法有两种::mean_c 和 guassian_c
- ADAPTIVE_THRESH_MEAN_C
opencv函数:
adaptiveThreshold(gray_src, dst, 255, cv::ADAPTIVE_THRESH_MEAN_C, cv::THRESH_BINARY, 57, 5);
- ADAPTIVE_THRESH_GAUSSIAN_C
opencv函数:
adaptiveThreshold(gray_src, dst, cv.ADAPTIVE_THRESH_GAUSSIAN_C, cv.THRESH_BINARY, 25, 10)
边栏推荐
- Xiaomi mobile phone SMS location service activation failed
- 如何修改数据库密码
- Talking about the understanding of CAP in distributed mode
- cocoscreator3.5.2打包微信小游戏发布到QQ小游戏修改
- The feign call fails, JSON parse error Illegal character ((CTRL-CHAR, code 31)) only regular white space (r
- Notes on creating a new virtual machine in Hyper-V
- Gradle sync failed: Uninitialized object exists on backward branch 142
- Chinese garbled solution in UTF-8 environment in Powershell
- 活体检测CDCN学习笔记
- [swagger close] The production environment closes the swagger method
猜你喜欢

npm WARN config global `--global`, `--local` are deprecated. Use `--location solution

Tencent Cloud GPU Desktop Server Driver Installation

对js的数组的理解

MySql to create data tables

Nmap的下载与安装
![[Cloud Native] What should I do if SQL (and stored procedures) run too slowly?](/img/40/be3a30743ee2bc6c82f82ab852f29c.png)
[Cloud Native] What should I do if SQL (and stored procedures) run too slowly?

Numpy常用函数

【解决问题】RuntimeError: The size of tensor a (80) must match the size of tensor b (56) at non-singleton

QT VS中双击ui文件无法打开的问题

Gradle sync failed: Uninitialized object exists on backward branch 142
随机推荐
数据库 | SQL查询进阶语法
著名网站msdn.itellyou.cn原理分析
微信小程序源码获取与反编译方式
MYSQL transaction and lock problem handling
js中流程控制语句
Sqlite A列数据复制到B列
function in js
【解决问题】RuntimeError: The size of tensor a (80) must match the size of tensor b (56) at non-singleton
TransactionTemplate 事务编程式写法
podspec自动化升级脚本
unicloud 发布后小程序提示连接本地调试服务失败,请检查客户端是否和主机在同一局域网下
quick-3.5 无法正常显示有混合纹理的csb文件
一文速学-玩转MySQL获取时间、格式转换各类操作方法详解
腾讯云GPU桌面服务器驱动安装
CNN的一点理解
[swagger close] The production environment closes the swagger method
Sourcery插件(自动提升代码质量)
Markdown help documentation
Nmap的下载与安装
UiBot has an open Microsoft Edge browser and cannot perform the installation