当前位置:网站首页>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)
边栏推荐
- CNN的一点理解
- sqlite 查看表结构 android.database.sqlite.SQLiteException: table splitTable has no column named
- MYSQL事务与锁问题处理
- Markdown 帮助文档
- Pure shell implementation of text replacement
- 微信小程序源码获取与反编译方式
- Pytorch常用函数
- ERROR Error: No module factory availabl at Object.PROJECT_CONFIG_JSON_NOT_VALID_OR_NOT_EXIST ‘Error
- 纯shell实现文本替换
- flutter arr dependencies
猜你喜欢

The browser looks for events bound or listened to by js

腾讯云GPU桌面服务器驱动安装

JS写一段代码,判断一个字符串中出现次数最多的字符串,并统计出现的次数JS

Sqlite column A data is copied to column B

js中的this指向与原型对象

UiBot has an open Microsoft Edge browser and cannot perform the installation

This in js points to the prototype object

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

一文速学-玩转MySQL获取时间、格式转换各类操作方法详解

DC-CDN学习笔记
随机推荐
Several forms of Attribute Changer
通信原理——纠错编码 | 汉明码(海明码)手算详解
活体检测FaceBagNet阅读笔记
浏览器查找js绑定或者监听的事件
flutter arr dependencies
Chinese garbled solution in UTF-8 environment in Powershell
How MySQL - depots table?A look at will understand
Pure shell implementation of text replacement
CNN的一点理解
SQLite 查询表中每天插入的数量
数据库 | SQL增删改查基础语法
360 加固 file path not exists.
Multi-Modal Face Anti-Spoofing Based on Central Difference Networks学习笔记
TransactionTemplate 事务编程式写法
understand js operators
Principle analysis of famous website msdn.itellyou.cn
[swagger close] The production environment closes the swagger method
动态规划(一)| 斐波那契数列和归递
Sourcery插件(自动提升代码质量)
Tencent Cloud Lightweight Server deletes all firewall rules