当前位置:网站首页>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 查看。
边栏推荐
- Scala基础教程--13--函数进阶
- 大佬们,求助一下,我用mysql cdc 2.2.1(flink 1.14.5)写入kafka,设置
- Scala基础教程--15--递归
- Scala基础教程--18--集合(二)
- A method of using tree LSTM reinforcement learning for connection sequence selection
- 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
- 启牛开的证券账户安全吗?
- 【uniapp】uniapp开发app在线预览pdf文件
- 请教一下 flinksql中 除了数据统计结果是状态被保存 数据本身也是状态吗
- Pb extended DLL development (super chapter) (VII)
猜你喜欢
读写关闭的channel是啥后果?
Summary and sorting of 8 pits of redis distributed lock
中国农科院基因组所汪鸿儒课题组诚邀加入
Scala basic tutorial -- 15 -- recursion
Scala basic tutorial -- 20 -- akka
从实时应用角度谈通信总线仲裁机制和网络流控
DeFi生态NFT流动性挖矿系统开发搭建
Nebula importer data import practice
LeetCode第300场周赛(20220703)
Nature microbiology | viral genomes in six deep-sea sediments that can infect Archaea asgardii
随机推荐
Go微服务(二)——Protobuf详细入门
What if the self incrementing ID of online MySQL is exhausted?
redis分布式锁的8大坑总结梳理
正则替换【JS,正则表达式】
2021 Hefei informatics competition primary school group
Rookie post station management system based on C language
Scala基础教程--18--集合(二)
1、 Introduction to C language
prometheus安装
Pb extended DLL development (super chapter) (VII)
2022健康展,北京健博会,中国健康展,大健康展11月13日
From automation to digital twins, what can Tupo do?
C # implementation defines a set of SQL statements that can be executed across databases in the middle of SQL (detailed explanation of the case)
删除字符串中出现次数最少的字符【JS,Map排序,正则】
How to modify icons in VBS or VBE
2019年蜀山区第十五届青少年信息学竞赛
Li Chi's work and life summary in June 2022
学习路之PHP--phpstudy创建项目时“hosts文件不存在或被阻止打开”
6.26CF模拟赛B:数组缩减题解
Unity给自己的脚本添加类似编辑器扩展的功能案例ContextMenu的使用