当前位置:网站首页>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 查看。
边栏推荐
- Wanghongru research group of Institute of genomics, Chinese Academy of Agricultural Sciences is cordially invited to join
- Scala基础教程--18--集合(二)
- 英特尔集成光电研究最新进展推动共封装光学和光互连技术进步
- 资料下载 丨首届腾讯技术开放日课程精华!
- 876. 链表的中间结点
- Lex and yacc based lexical analyzer + parser
- LeetCode FizzBuzz C#解答
- [release] a tool for testing WebService and database connection - dbtest v1.0
- 【机器学习的数学基础】(一)线性代数(Linear Algebra)(上+)
- Technology sharing | interface testing value and system
猜你喜欢

Lex and yacc based lexical analyzer + parser

2022CoCa: Contrastive Captioners are Image-Text Fountion Models

The latest progress of Intel Integrated Optoelectronics Research promotes the progress of CO packaging optics and optical interconnection technology

读写关闭的channel是啥后果?

学习路之PHP--phpstudy创建项目时“hosts文件不存在或被阻止打开”

How to modify icons in VBS or VBE

Learning path PHP -- phpstudy "hosts file does not exist or is blocked from opening" when creating the project

Safer, smarter and more refined, Chang'an Lumin Wanmei Hongguang Mini EV?

DeFi生态NFT流动性挖矿系统开发搭建

My colleagues quietly told me that flying Book notification can still play like this
随机推荐
Scala基础教程--18--集合(二)
node_exporter部署
Scala basic tutorial -- 15 -- recursion
ThreadLocal原理与使用
2022年字节跳动日常实习面经(抖音)
2014合肥市第三十一届青少年信息学奥林匹克竞赛(小学组)试题
Bi skills - permission axis
[2022 Jiangxi graduate mathematical modeling] curling movement idea analysis and code implementation
Nebula importer data import practice
Installation and use of VMware Tools and open VM tools: solve the problems of incomplete screen and unable to transfer files of virtual machines
2022CoCa: Contrastive Captioners are Image-Text Fountion Models
IBM WebSphere MQ检索邮件
【uniapp】uniapp开发app在线预览pdf文件
Guys, for help, I use MySQL CDC 2.2.1 (Flink 1.14.5) to write Kafka and set
Li Kou brush question diary /day4/6.26
MXNet对GoogLeNet的实现(并行连结网络)
Scala基础教程--16--泛型
Wireshark packet capturing TLS protocol bar displays version inconsistency
Nebula Importer 数据导入实践
2022健康展,北京健博会,中国健康展,大健康展11月13日