matlab形态学图像处理之strel函数

转自:http://blog.sina.com.cn/s/blog_b1cd5d330101pmwi.html

strel——structuring element 运用各种形状和大小构造元素,基本语法为

SE = strel(shape, parameters)

shape 是指定希望形状的字符串,parameters 是指定形状信息的一系列参数

SE = strel('arbitrary', NHOOD)

创建一个任意形状的结构元素,NHOOD是由0和1组成的矩阵,用于指定形状可以用se=strel(NHOOD)简化

SE = strel('arbitrary', NHOOD, HEIGHT)

HEIGHT是一个与NHOOD同样大小的矩阵,包含与相关的NHOOD中非零元素的高度值

SE = strel('ball', R, H, N)

creates a nonflat, ball-shaped structuring element (actually an ellipsoid) whose radius in the X-Y plane is R and whose height is H.

When N is greater than 0, the ball-shaped structuring element is approximated by a sequence of N nonflat, line-shaped structuring elements. When N equals 0, no approximation is used, and the structuring element members consist of all pixels whose centers are no greater than R away from the origin.

SE = strel('diamond', R)

创建一个平坦的菱形结构元素,R是从结构元素原点到菱形最远的距离

SE = strel('disk', R, N)

创建一个平坦的圆形结构元素,半径为R。

N必须是0,4,6 或8。当N比0大时,圆形结构元素被N个周期线型( periodic-line )结构元素序列近似,当N等于0时,没有近似,结构元素包含所有的小于从原点到R的像素。

se=strel('disk',5,0)

0 0 0 0 0 1 0 0 0 0 0

0 0 1 1 1 1 1 1 1 0 0

0 1 1 1 1 1 1 1 1 1 0

0 1 1 1 1 1 1 1 1 1 0

0 1 1 1 1 1 1 1 1 1 0

1 1 1 1 1 1 1 1 1 1 1

0 1 1 1 1 1 1 1 1 1 0

0 1 1 1 1 1 1 1 1 1 0

0 1 1 1 1 1 1 1 1 1 0

0 0 1 1 1 1 1 1 1 0 0

0 0 0 0 0 1 0 0 0 0 0

se=strel('disk',5,4)

0 0 1 1 1 1 1 0 0

0 1 1 1 1 1 1 1 0

1 1 1 1 1 1 1 1 1

1 1 1 1 1 1 1 1 1

1 1 1 1 1 1 1 1 1

1 1 1 1 1 1 1 1 1

1 1 1 1 1 1 1 1 1

0 1 1 1 1 1 1 1 0

0 0 1 1 1 1 1 0 0

SE = strel('line', LEN, DEG)

创建一个平坦的线型结构,LEN长度,DEG角度

SE = strel('octagon', R)

创建一个平坦的八边形结构元素,R是从结构元素原点到八边形边的距离,沿水平轴和垂直轴的度量,R必须是3的非负倍数

SE = strel('pair', OFFSET)

创建一个包含两个成员的平坦结构元素,一个成员在原点,另一个成员由向量OFFSET表示,该向量必须是一个两元素的整数向量

SE = strel('periodicline', P, V)

创建一个包含有2*P+1个成员的平坦元素,其中V是一个两元素向量,它包含有整数值的行和列的偏移,一个元素在原点,另一个位于

1*V, -1*V, 2*V, -2*V, ..., P*V, -P*V.

se=strel('periodicline',2,[1 -2])

0 0 0 0 0 0 0 0 1

0 0 0 0 0 0 1 0 0

0 0 0 0 1 0 0 0 0

0 0 1 0 0 0 0 0 0

1 0 0 0 0 0 0 0 0

SE = strel('rectangle', MN)

创建一个平坦的矩形结构,MN指定大小

SE = strel('square', W)

创建一个方形的结构元素,边长为N个像素

------------------------------------------------------

Matlab中函数strel在操作结构元素应用,用于膨胀腐蚀及开闭运算等操作的结构元素对象

具体用法:SE = strel(shape,parameters)

创建由指定形状shape对应的结构元素。其中shape的种类有

arbitrary'

'pair'

'diamond'

'periodicline'

'disk'

'rectangle'

'line'

'square'

'octagon

参数parameters一般控制SE的大小。

实验现象:

SE = strel('diamond', 3)

SE =

Flat STREL object containing 25 neighbors.

Decomposition: 3 STREL objects containing a total of 13 neighbors

Neighborhood:

0 0 0 1 0 0 0

0 0 1 1 1 0 0

0 1 1 1 1 1 0

1 1 1 1 1 1 1

0 1 1 1 1 1 0

0 0 1 1 1 0 0

0 0 0 1 0 0 0

>> se1 = strel('square',6)

se1 =

Flat STREL object containing 36 neighbors.

Decomposition: 2 STREL objects containing a total of 12 neighbors

Neighborhood:

1 1 1 1 1 1

1 1 1 1 1 1

1 1 1 1 1 1

1 1 1 1 1 1

1 1 1 1 1 1

1 1 1 1 1 1

>> se2 = strel('line',10,45)

se2 =

Flat STREL object containing 7 neighbors.

Neighborhood:

0 0 0 0 0 0 1

0 0 0 0 0 1 0

0 0 0 0 1 0 0

0 0 0 1 0 0 0

0 0 1 0 0 0 0

0 1 0 0 0 0 0

1 0 0 0 0 0 0