当前位置:网站首页>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 查看。
边栏推荐
- 神经网络物联网应用技术学什么
- Go microservice (II) - detailed introduction to protobuf
- Cache é JSON uses JSON adapters
- Bi skills - permission axis
- Mxnet implementation of googlenet (parallel connection network)
- LeetCode 赎金信 C#解答
- 2014合肥市第三十一届青少年信息学奥林匹克竞赛(小学组)试题
- Download the first Tencent technology open day course essence!
- 信息学奥赛一本通 1336:【例3-1】找树根和孩子
- Scala basic tutorial -- 15 -- recursion
猜你喜欢

Scala basic tutorial -- 15 -- recursion

更安全、更智能、更精致,长安Lumin完虐宏光MINI EV?

Scala基础教程--15--递归

千万不要只学 Oracle、MySQL!

【uniapp】uniapp开发app在线预览pdf文件

基于C语言的菜鸟驿站管理系统
![[release] a tool for testing WebService and database connection - dbtest v1.0](/img/4e/4154fec22035725d6c7aecd3371b05.jpg)
[release] a tool for testing WebService and database connection - dbtest v1.0

Nebula Importer 数据导入实践

基于lex和yacc的词法分析器+语法分析器

Don't just learn Oracle and MySQL!
随机推荐
C语言打印练习
C # implementation defines a set of SQL statements that can be executed across databases in the middle of SQL (detailed explanation of the case)
Caché JSON 使用JSON适配器
Scala基础教程--16--泛型
sqlserver的CDC第一次查询的能读取到数据,但后面增删改读取不到,是什么原因
prometheus安装
876. 链表的中间结点
1、 Introduction to C language
工厂从自动化到数字孪生,图扑能干什么?
Is Guoyuan futures a regular platform? Is it safe to open an account in Guoyuan futures?
Torchdrug tutorial
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
Scala basic tutorial -- 12 -- Reading and writing data
Installation and use of VMware Tools and open VM tools: solve the problems of incomplete screen and unable to transfer files of virtual machines
From automation to digital twins, what can Tupo do?
从实时应用角度谈通信总线仲裁机制和网络流控
Scala基础教程--14--隐式转换
Go微服务(二)——Protobuf详细入门
Process of manually encrypt the mass-producing firmware and programming ESP devices
2014 Hefei 31st youth informatics Olympic Games (primary school group) test questions