(三)OpenCV函数

1 morphologyEx()

功能:执行高级形态转换.
参数描述

序号参数描述
1src输入图像,任意通道数,图像深度为CV_8U,CV_16U,CV_16S,CV_32F或CV_64F
2dst输出图像,尺寸和类型与输入相同
3op形态变换类型
4kernel元素结构,可由getStructuringElement创建
5anchor核的停靠点,负值说明锚是核中心
6iterations迭代次数
7borderType像素外推方法
8borderValue边框值为常值的边框

2 MorphTypes

功能:形态学操作类型.
参数描述

序号参数描述
1MORPH_ERODE如下3
2MORPH_DILATEdilate
3MORPH_OPEN d s t = o p e n ( s r c , e l e m e n t ) = d i l a t e ( e r o d e ( s r c , e l e m e n t ) ) dst=open(src, element)=dilate(erode(src, element)) dst=open(src,element)=dilate(erode(src,element))
4MORPH_CLOSE d s t = c l o s e ( s r c , e l e m e n t ) = e r o d e ( d i l a t e ( s r c , e l e m e n t ) ) dst=close(src, element)=erode(dilate(src, element)) dst=close(src,element)=erode(dilate(src,element))
5MORPH_GRADIENT d s t = m o r p h g r a d ( s r c , e l e m e n t ) = d i l a t e ( s r c , e l e m e n t ) − e r o d e ( s r c , e l e m e n t ) dst=morph_grad(src, element)=dilate(src, element)-erode(src, element) dst=morphgrad(src,element)=dilate(src,element)erode(src,element)
6MORPH_TOPHAT d s t = t o p h a t ( s r c , e l e m e n t ) = s r c − o p e n ( s r c , e l e m e n t ) dst=tophat(src, element)=src-open(src, element) dst=tophat(src,element)=srcopen(src,element)
7MORPH_BLACKHAT d s t = b l a c k h a t ( s r c , e l e m e n t ) = c l o s e ( s r c , e l e m e n t ) = s r c dst=blackhat(src, element)=close(src, element)=src dst=blackhat(src,element)=close(src,element)=src
8MORPH_HITMISS

3 erode()

功能:使用特定元素结构腐蚀图像.
参数描述

序号参数描述
1src输入图像,任何通道的数据,深度必须满足CV_8U,CV_16U,CV_16S,CV_32F,CV_64F
2dst输出图像,尺寸和类型与源图像一致
3kernel用于扩充的结构单元,如果单元为矩阵,3 × \times × 3的结构单元即可使用,核可使用getStructuringElement创建
4anchor含有锚点结构的位置,默认值为(-1,-1),是结构中心
5iterations扩充的次数
6borderType像素外推方法
7borderValue边框为常量是的边框值

计算方式:
d s t ( x , y ) = m i n ( x ′ , y ′ ) : e l e m e n t ( x ′ , y ′ ) ≠ 0 s r c ( x + x ′ , y + y ′ ) dst(x,y)=min_{(x',y'):element(x',y')\not=0}src(x+x', y+y') dst(x,y)=min(x,y):element(x,y)=0src(x+x,y+y)

4 getStructuringElement()

功能:返回形态学处理后具有特定尺寸和维度的元素结构.
参数描述

序号参数描述
1shape元素维度为MorphShapes的一种
2ksize元素结构尺寸
3anchor元素锚点位置,默认(-1,-1)即锚点中心

5 MorphShapes

功能:元素结构维度.
参数描述

序号参数描述
1MORPH_RECT矩形元素结构 E i j = 1 E_{ij}=1 Eij=1
2MORPH_CROSS十字形元素结构, E i j = { 1 i f i = anchor.y o r j = anchor.x 0 otherwise E_{ij}=\begin{cases}1 &\text{}if& i=\texttt{anchor.y} &or& j=\texttt{anchor.x}\\ 0 &\text{otherwise}\end{cases} Eij={10ifotherwisei=anchor.yorj=anchor.x
3MORPH_ELLIPSE椭圆元素结构,刻在矩形上的实心椭圆,Rect(0,0,esize.width,0, esize.height)

【参考文献】
[1]https://docs.opencv.org/4.1.2/

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值