数学形态学

ERDAS 数学形态学(Morphological)运算(其中包含腐蚀Erode、膨胀Dilate、开运算Open、闭运算Close)-Python CV2库

老子叫甜甜 提交于 2019-12-22 23:03:26
ERDAS数学形态学(Morphological)运算,其中包含腐蚀(Erode)、膨胀(Dilate)、开运算(Open)、闭运算(Close) 在用ERDAS Imagine 2014做水体提取时,需要用到形态学运算,在软件菜单栏"Rster tab → Spatial → Morphological"工具下有个Function选择列表,里面有Erode(腐蚀)、Dilate(膨胀)、Open(开运算)、Close(闭运算)这四个函数,今天我们用Python的CV2库对相关的概念做一下深入地理解。(附源代码) 前期准备: 模版的选择: 3*3的矩形结构模版 kernel01 = cv . getStructuringElement ( cv . MORPH_RECT , ( 3 , 3 ) ) # 矩形结构 [[1 1 1] [1 1 1] [1 1 1]] 5*5的椭圆结构模版 kernel02 = cv . getStructuringElement ( cv . MORPH_ELLIPSE , ( 3 , 3 ) ) # 椭圆结构 [[0 0 1 0 0] [1 1 1 1 1] [1 1 1 1 1] [1 1 1 1 1] [0 0 1 0 0]] 3*3的十字结构模版 kernel03 = cv . getStructuringElement ( cv .