腐蚀和膨胀

来源:互联网 发布:淘宝卖蜂蜜需要什么 编辑:程序博客网 时间:2024/05/09 04:31
Matlab中函数strel在操作结构元素应用,用于膨胀腐蚀及开闭运算等操作的结构元素对象(构造结构元素)
具体用法:SE = strel(shape,parameters)
创建由指定形状shape对应的结构元素。其中shape的种类有
arbitrary'
'pair'
'diamond'
'periodicline'
'disk'
'rectangle'
'line'
'square'
'octagon
参数parameters一般控制SE的大小。

例子:
se1 = strel('square',6)
% 创建6*6的正方形
se2 = strel('line',10,45)
% 创建直线长度10,角度45
se3 = strel('disk',15)
% 创建圆盘半径15

se4 = strel('ball',15,5)

% 创建椭圆体,半径15,高度5

matlab中灰度膨胀函数为 imdilate()

比如:

I= imread('circles.png');

subplot(121);imshow(I); title('原图像');

se = strel('disk',10);

I2 = imdilate(I,se);

subplot(122);imshow(I2);title('膨胀图像');

灰度腐蚀用函数 imerode()

比如: 

I = imread('circles.png');  

subplot(121);imshow(I); title('原图像');

se = strel('disk',11);        

I2 = imerode(I,se);

subplot(122);imshow(I2);title('腐蚀图像');


0 0