Erode and Dilate

图像的像素值越大的地方,图像越亮,而腐蚀和膨胀就是求图像像素局部最小值和局部最大值的过程

膨胀(dilate):就是对图像的高亮部分进行膨胀,相当于高亮部分的领域扩张

腐蚀(erode):就是对图像的高亮部分的侵蚀,也就是经过腐蚀操作之后图像的高亮部分变得更少

  • The larger the pixel value of the image, the brighter the image, and corrosion and expansion is the process of finding the local minimum and local maximum of the image pixel
  • Dilate: Dilate the highlighted part of the image, equivalent to the field expansion of the highlighted part
  • Erode: The edge of the image is eroded, or the edge of the image becomes less intense after the erosion operation

1.膨胀与腐蚀的原理:

首先,在腐蚀与膨胀的操作过程中,我们得给出一个核窗口,它有一个单独定义出来的参考点,我们称之为锚点,(这个窗口的给出我们一般会结合函数getStructuringElement使用,这个函数的用法我们一会儿来介绍),然后我们把这个窗口在原图像上滑动,计算原图像在这个窗口覆盖部分之下的最值,然后把这个最值赋值给参考点指定的像素

如果这个最值是最大值,那么上述操作就是膨胀dilate,它会使原图像高亮部分的领域逐渐扩张

如果这个最值是最小值,那么上述操作就是腐蚀erode,它会使原图像高亮部分的领域被侵蚀

  • 1. Principles of expansion and corrosion:
  • First of all, in the process of corrosion and the expansion of the operation, we have to give a window, it has a separate defined reference point, we call it the anchor, (this window shows we usually getStructuringElement used in combination with functions, the function of usage to introduce to you soon), then we put this window sliding on the original image, calculate the original image under the window covering part of the value, then the most value assigned to the reference point specified pixel
  • If the maximum value is the maximum, then the above operation is dilate dilate, which will gradually expand the highlighted area of the original image
  • If this maximum is the minimum, the above operation is the erode erode, which erode the areas highlighted by the original image

2.dilate函数的使用方法:

我们来看看它的函数原型:

void dilate( const Mat& src, Mat& dst, const Mat& element,Point anchor=Point(-1,-1), int iterations=1,int borderType=BORDER_CONSTANT,

const Scalar& borderValue=morphologyDefaultBorderValue() );

第一个参数:输入图像

第二个参数:输出图像,要和原图像有一样的尺寸和类型

第三个参数:原图像类型的element,膨胀操作的核,当为NULL时表示使用的是参考点位于中心的3x3的核(通常使用函数getStructuringElement来计算)

第四个参数:锚点位置,有默认值Point(-1, -1)

第五个参数:迭代使用dilate的次数,默认值为1

第六个参数:有默认值BORDER_DEFAULT

第七个参数:const Scalar类型的 borderValue,一般不用管他

其实一般我们使用的时候,大部分只需要填前三个参数,后面四个都有默认值

  • 2. Use of DILate function:
  • Let's take a look at its functional prototype:
  • Void dilate(const Mat& SRC, Mat& DST, Const Mat& Element,Point anchor=Point(-1,-1), int iterations=1,int borderType=BORDER_CONSTANT,
  • Const Scalar & borderValue = morphologyDefaultBorderValue ());
  • The first parameter: Enter the image
  • Second parameter: output image with the same size and type as the original image
  • Third argument: element of the original image type, core of the expansion operation, when NULL means that the 3x3 core with the reference point in the center is used (usually calculated using the function getStructuringElement)
  • Fourth parameter: anchor position with default value Point(-1, -1)
  • The fifth parameter: the number of times dilate is used in the iteration, with the default value of 1
  • Parameter 6: Has the default value, BORDER_DEFAULT
  • The seventh parameter: the Const Scalar type's borderValue, which will generally leave him alone
  • In fact, when we use it, most of us only need to fill in the first three parameters, and the last four have default values

3. getStructuringElement函数的使用方法:

第一个参数:内核的形状,有下面三种形状可以选择:

MORPH_RECT : 矩形

MORPH_CROSS : 交叉形

MORPH_ELLIPSE : 椭圆形

Size类型的内核的尺寸

Point类型的锚点的位置,有默认值Point(-1, -1)

注意:交叉型的element形状唯一依赖于锚点的位置,其他情况下,锚点的位置只是影响到了形态学运算结果的偏移

Mat element = getStructuringElement(MORPH_RECT, Size(5, 5), Point(-1, -1));

  • 3. Use method of getStructuringElement function:
  • The first parameter is the shape of the kernel. There are three shapes to choose from:
  • MORPH_RECT: rectangle
  • MORPH_CROSS: MORPH_CROSS
  • Ellipse: An ellipse
  • Size the Size of the kernel
  • The location of an anchor Point of type Point, with the default value Point(-1, -1)
  • Note: Cross-shaped element shapes depend solely on the location of anchor points. In other cases, the location of anchor points only affects the deviation of morphological operations
  • Here's an example:
  • Mat Element = getStructuringElement(MORPH_RECT, Size(5, 5), Point(-1, -1));

3.dilate函数的使用方法

下面是函数原型:

void dilate( const Mat& src, Mat& dst, const Mat& element,Point anchor=Point(-1,-1), int iterations=1,int borderType=BORDER_CONSTANT,

const Scalar& borderValue=morphologyDefaultBorderValue() );

第一个参数:原图像

第二个参数:输出图像

第三个参数:和输入图像一样类型的核,通常配合getStructuringElement函数使用

第四个参数:Point类型的锚点的位置,有默认值(-1, -1)

第五个参数:int类型的迭代使用dilate函数的次数,默认值为1

第六个参数:有默认值BORDER_DEFAULT

第七个参数:const Scalar类型的 borderValue,一般不用管他

  • 3. Use of DILate function
  • Here is the function prototype:
  • Void dilate(const Mat& SRC, Mat& DST, Const Mat& Element,Point anchor=Point(-1,-1), int iterations=1,int borderType=BORDER_CONSTANT,

  • Const Scalar & borderValue = morphologyDefaultBorderValue ());

  • The first parameter: the original image

  • Second parameter: Output image

  • Third argument: a core of the same type as the input image, usually used with the getStructuringElement function

  • Fourth parameter: the location of the anchor Point of type Point, with default value (-1, -1)

  • Parameter 5: The number of times an int iteration USES the DILate function, with the default value of 1

  • Parameter 6: Has the default value, BORDER_DEFAULT

  • The seventh parameter: the Const Scalar type's borderValue, which will generally leave him alone

C++ opencv Erode and Dilate相关推荐

  1. OpenCV-Python图像处理:腐蚀和膨胀原理及erode、dilate函数介绍

    ☞ ░ 前往老猿Python博客 https://blog.csdn.net/LaoYuanPython ░ 一.引言 关于图像的腐蚀和膨胀,网上介绍的资料非常多,老猿也看了很多,总体来说主要偏向于就 ...

  2. OpenCV morphologyEx、erode、dilate、getStructuringElement (形态学算子)

    ::返回OpenCV算子速查表 OpenCV getStructuringElement 1. 函数 1.1 getStructuringElement 1.2 morphologyEx 1.3 er ...

  3. OpenCV 常用函数汇总(normalize、getStructuringElement、erode、dilate)

    简单认知 Mat 认知 取值类型和范围 CV_8U 8位无符号整数 0~255 CV_8S 8位符号整数 -128~127 CV_16U 16位无符号整数 0~65535 CV_16S 16位符号整数 ...

  4. Opencv中的erode和dilate(腐蚀和膨胀-python实现)

    文章目录 1.腐蚀原理 (1)具体实现过程 (2).函数讲解 (3).代码实战 2.膨胀原理 (1)具体实现过程 (2)函数讲解 (3)代码实现 1.腐蚀原理 (1)具体实现过程 腐蚀会把物体的边界腐 ...

  5. OPenCV膨胀函数dilate()的使用

    OPenCV版本:4.4 IDE:VS2017 功能描述 简述:使用一个指定的核元素去膨胀一个图像,图像膨胀的过程类似于一个卷积的过程,源图像矩阵A以及结构元素B,B在A矩阵上依次移动,每个位置上B所 ...

  6. 腐蚀和膨胀(erode and dilate)

    腐蚀和膨胀 在这两个操作中都需要有一个滑动窗口一样的小块,这个小块在整副图像上面进行一个像素一个像素的滑动. 膨胀 膨胀操作:当前像素值等于该小块覆盖下的图像区域的最大像素值. 从而当背景色为白色,字 ...

  7. python opencv 腐蚀_opencv 图像的腐蚀(erode)和膨胀(dilate) 开运算以及闭运算

    原文链接:opencv 图像的腐蚀(erode)和膨胀(dilate) 开运算以及闭运算 OpenCV---开闭操作 - 山上有风景 - 博客园 腐蚀 : 腐蚀操作会把前景物体的边缘腐蚀掉.原理是卷积 ...

  8. opencv形态学运算:腐蚀(erode)和膨胀(dilate)

    形态学操作就是基于形状的一系列图像处理操作.OpenCV为进行图像的形态学变换提供了快捷.方便的函数.最基本的形态学操作有二种,他们是:膨胀与腐蚀(Dilation与Erosion). 膨胀与腐蚀能实 ...

  9. OPENCV入门教程十一:dilate图像膨胀

    一.目标 学习如何使用opencv中的函数,学习对图像的膨胀操作,学习dilate()函数的使用 二.函数说明 函数原型: dilate(InputArray src,OutputArray dst, ...

最新文章

  1. 顶会论文9篇,又斩获百度奖学金!哈工大NLP“新生代”正崭露头角
  2. 高级特性(4)- 数据库编程
  3. 地址栏射击游戏!对,你没看错,就是在地址栏上玩的游戏,有图有真相!
  4. opencv 图像的腐蚀与膨胀
  5. 神经网络的反向传导到底是在干什么?
  6. 【DIY】入门必看:arduino入门实用教程,esp8266获取互联网时间,nodemcu制作NTP客户端获取显示互联网时间...
  7. 模块化是数据中心设计的未来
  8. android 游戏 重力
  9. python下雨动画特效_pygame用blit()实现动画效果
  10. Tomcat_Servlet
  11. java代码审计文件包含_代码审计--一道简单的文件包含题目的多种利用方式
  12. thinkphp框架知识点
  13. JS判断是否在微信浏览器打开
  14. Windows Server 2012和2016从Evaluation评估版升级到正式版方法(附带产品密钥/key)
  15. 小米10 红米K30Pro 小米10Pro 无限重启卡米 9008救砖后无限重启 线刷无效
  16. Apache Log4j2远程代码执行漏洞复现
  17. html怎么统计总访问量,如何实现对网站页面访问量的统计?
  18. codeforces C. Team
  19. 思科C2960交换机的默认网关
  20. 服务器mtu值修改,更改服务器mtu值

热门文章

  1. linux播放器切换,让mplayer成为linux下的万能播放器(更新)
  2. python虚拟环境搭建安装flask框架_Flask框架搭建虚拟环境的步骤分析
  3. NLTK库来咬文嚼字
  4. 数字逻辑组合电路分析练习题
  5. 栈结构应用_普通计算器和逆波兰计算器
  6. 4 Vue中的Ajax
  7. Windows系统下MySQL8.0版详细安装及配置教程
  8. 期刊印刷时间大概多久
  9. IIS服务器为什么页面显示404,windows系统IIS服务器怎么正确设置404页面?
  10. hdu 4160 (Dolls)二分图的最小路径覆盖