膨胀与腐蚀

形态学操作

    形态学操作就是基于形状的一些列图像处理操作。通过结构元素作用于输入图像产生输出图像。

    结构元素,就是形态学操作的处理内核。通过内核与图像的卷积完成处理过程。内核可以有各种形状如矩形,圆形,菱形。结构元素的锚点(即与处理元素重合的点)默认为中心(参数cv::Point()-1,-1).opencv一般默认3*3的结构元素,我们也可以自己定义1,3,5,7尺寸的结构元素。例如定义一个7*7的cv::Mat element(7,7,CV_8U,Scalar(1)).

一般情况下形态学操作针对的是单通道图。


最基本的形态学操作有二:腐蚀与膨胀(Erosion 与 Dilation)。 他们的运用广泛:

消除噪声

分割(isolate)独立的图像元素,以及连接(join)相邻的元素。

寻找图像中的明显的极大值区域或极小值区域。

cv::dilate(cornerStrength,dilated,cv::Mat());
  cv::compare(cornerStrength,dilataed,localMax,cv::CMP_EQ);
利用膨胀是用最大值替换的原则,只有最大值不变,将区域中的最大值位置提取出来


膨胀腐蚀是针对较大的元素而言的,故膨胀是亮色的膨胀(暗色腐蚀),腐蚀是亮色的腐蚀(暗色膨胀)


void  erode (const  Mat&  srcMat&  dst, const  Mat&  element, Point  anchor=Point(-1, -1), int  iterations=1, int  borderType=BORDER_CONSTANT, const Scalar& borderValue=morphologyDefaultBorderValue() )

Erodes an image by using a specific structuring element.


Parameters:
  • src – The source image
  • dst – The destination image. It will have the same size and the same type as src
  • element – The structuring element used for dilation. If element=Mat() , a 3\times 3 rectangular structuring element is used
  • anchor – Position of the anchor within the element. The default value (-1, -1) means that the anchor is at the element center
  • iterations – The number of times erosion is applied
  • borderType – The pixel extrapolation method; see borderInterpolate()
  • borderValue – The border value in case of a constant border. The default value has a special meaning, see createMorphoogyFilter()

The function erodes the source image using the specified structuring element that determines the shape of a pixel neighborhood over which the minimum is taken:


The function supports the in-place mode. Erosion can be applied several ( iterations ) times. In the case of multi-channel images each channel is processed independently.



void  erode (const  Mat&  srcMat&  dst, const  Mat&  element, Point  anchor=Point(-1, -1), int  iterations=1, int  borderType=BORDER_CONSTANT, const Scalar& borderValue=morphologyDefaultBorderValue() )

Erodes an image by using a specific structuring element.

Parameters:
  • src – The source image
  • dst – The destination image. It will have the same size and the same type as src
  • element – The structuring element used for dilation. If element=Mat() , a 3\times 3 rectangular structuring element is used
  • anchor – Position of the anchor within the element. The default value (-1, -1) means that the anchor is at the element center
  • iterations – The number of times erosion is applied
  • borderType – The pixel extrapolation method; see borderInterpolate()
  • borderValue – The border value in case of a constant border. The default value has a special meaning, see createMorphoogyFilter()

The function erodes the source image using the specified structuring element that determines the shape of a pixel neighborhood over which the minimum is taken:

\texttt{dst} (x,y) =  \min _{(x',y'):  \, \texttt{element} (x',y') \ne0 } \texttt{src} (x+x',y+y')

The function supports the in-place mode. Erosion can be applied several ( iterations ) times. In the case of multi-channel images each channel is processed independently.

 




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值