1 morphologyEx()
功能:执行高级形态转换.
参数描述
序号 | 参数 | 描述 |
---|---|---|
1 | src | 输入图像,任意通道数,图像深度为CV_8U,CV_16U,CV_16S,CV_32F或CV_64F |
2 | dst | 输出图像,尺寸和类型与输入相同 |
3 | op | 形态变换类型 |
4 | kernel | 元素结构,可由getStructuringElement创建 |
5 | anchor | 核的停靠点,负值说明锚是核中心 |
6 | iterations | 迭代次数 |
7 | borderType | 像素外推方法 |
8 | borderValue | 边框值为常值的边框 |
2 MorphTypes
功能:形态学操作类型.
参数描述
序号 | 参数 | 描述 |
---|---|---|
1 | MORPH_ERODE | 如下3 |
2 | MORPH_DILATE | dilate |
3 | MORPH_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)) |
4 | MORPH_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)) |
5 | MORPH_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) |
6 | MORPH_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)=src−open(src,element) |
7 | MORPH_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 |
8 | MORPH_HITMISS |
3 erode()
功能:使用特定元素结构腐蚀图像.
参数描述
序号 | 参数 | 描述 |
---|---|---|
1 | src | 输入图像,任何通道的数据,深度必须满足CV_8U,CV_16U,CV_16S,CV_32F,CV_64F |
2 | dst | 输出图像,尺寸和类型与源图像一致 |
3 | kernel | 用于扩充的结构单元,如果单元为矩阵,3 × \times × 3的结构单元即可使用,核可使用getStructuringElement创建 |
4 | anchor | 含有锚点结构的位置,默认值为(-1,-1),是结构中心 |
5 | iterations | 扩充的次数 |
6 | borderType | 像素外推方法 |
7 | borderValue | 边框为常量是的边框值 |
计算方式:
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()
功能:返回形态学处理后具有特定尺寸和维度的元素结构.
参数描述
序号 | 参数 | 描述 |
---|---|---|
1 | shape | 元素维度为MorphShapes的一种 |
2 | ksize | 元素结构尺寸 |
3 | anchor | 元素锚点位置,默认(-1,-1)即锚点中心 |
5 MorphShapes
功能:元素结构维度.
参数描述
序号 | 参数 | 描述 |
---|---|---|
1 | MORPH_RECT | 矩形元素结构 E i j = 1 E_{ij}=1 Eij=1 |
2 | MORPH_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 |
3 | MORPH_ELLIPSE | 椭圆元素结构,刻在矩形上的实心椭圆,Rect(0,0,esize.width,0, esize.height) |
【参考文献】
[1]https://docs.opencv.org/4.1.2/