当前位置:网站首页>OpenCV的二值化处理函数threshold()详解
OpenCV的二值化处理函数threshold()详解
2022-07-04 17:41:00 【昊虹图像算法】
二值化处理对于图像处理的重要意义就不多说了。
OpenCV提供了函数threshold()用于对图像作二值化处理。
其原型如下:
C++原型:
double cv::threshold( InputArray src,
OutputArray dst,
double thresh,
double maxval,
int type
)
Python原型如下:
retval, dst = cv.threshold(src, thresh, maxval, type[, dst])
参数意义如下:
src—输入图像,可以是多通道,8位或32位符点型数据类型的图像,但是当type选择THRESH_OTSU或THRESH_TRIANGLE时,图像只能8位的单通道图像。
dst—经过二值化处理的输出图像。
thresh—进行二值化处理的阈值。当type选择THRESH_OTSU或THRESH_TRIANGLE时,这个值被忽略,此时函数用通过OTSU法或TRIANGLE法计算出的阈值进行二值化操作。
maxval—二值化处理后的maxval值,详情见参数type的枚举值及其意义。当type选择THRESH_BINARY或THRESH_BINARY_INV时会用到它。
type—这个参数的可选枚举值及意义如下:
相比于C++的原型,在Python的原型中,返回参数有两个,第一个返回参数retval代表函数threshold()在进行二值化处理时使用的阈值的数值,这一点挺好,特别是对于type选择THRESH_OTSU或THRESH_TRIANGLE时,我们可以知道究竟用的阈值是多少。这个情况我曾经还写过博文,链接:https://blog.csdn.net/wenhao_ir/article/details/125188532
明白了各参数的意义和可取值后,应该就基本了解了这个函数的使用,接下只需要再看几个示例就能掌握了。
示例请各位移步博文 https://blog.csdn.net/wenhao_ir/article/details/125592598 查看。
边栏推荐
- sqlserver的CDC第一次查询的能读取到数据,但后面增删改读取不到,是什么原因
- C语言打印练习
- IBM WebSphere MQ检索邮件
- Scala基础教程--17--集合
- [go ~ 0 to 1] read, write and create files on the sixth day
- Scala basic tutorial -- 14 -- implicit conversion
- Scala基础教程--12--读写数据
- 从实时应用角度谈通信总线仲裁机制和网络流控
- Behind the ultra clear image quality of NBA Live Broadcast: an in-depth interpretation of Alibaba cloud video cloud "narrowband HD 2.0" technology
- Caché WebSocket
猜你喜欢

读写关闭的channel是啥后果?

使用canal配合rocketmq监听mysql的binlog日志

基于C语言的菜鸟驿站管理系统

2022 ByteDance daily practice experience (Tiktok)

Scala basic tutorial -- 15 -- recursion
![[go ~ 0 to 1] read, write and create files on the sixth day](/img/cb/b6785ad7d7c7df786f718892a0c058.png)
[go ~ 0 to 1] read, write and create files on the sixth day

小发猫物联网平台搭建与应用模型

2022CoCa: Contrastive Captioners are Image-Text Fountion Models

Deleting nodes in binary search tree

字节跳动Dev Better技术沙龙成功举办,携手华泰分享Web研发效能提升经验
随机推荐
2014合肥市第三十一届青少年信息学奥林匹克竞赛(小学组)试题
2021 Hefei informatics competition primary school group
Unity给自己的脚本添加类似编辑器扩展的功能案例ContextMenu的使用
Wireshark网络抓包
redis分布式锁的8大坑总结梳理
ByteDance dev better technology salon was successfully held, and we joined hands with Huatai to share our experience in improving the efficiency of web research and development
Nebula Importer 数据导入实践
The 15th youth informatics competition in Shushan District in 2019
Basic tutorial of scala -- 16 -- generics
2022-07-04: what is the output of the following go language code? A:true; B:false; C: Compilation error. package main import 'fmt' func
LeetCode第300场周赛(20220703)
整理混乱的头文件,我用include what you use
1672. 最富有客户的资产总量
Pb extended DLL development (super chapter) (VII)
From automation to digital twins, what can Tupo do?
Scala basic tutorial -- 12 -- Reading and writing data
Wireshark抓包TLS协议栏显示版本不一致问题
建立自己的网站(15)
MXNet对GoogLeNet的实现(并行连结网络)
2022年字节跳动日常实习面经(抖音)