PDA

查看完整版本 : [MATLAB图像处理] 求助!为什么下面运行结果不是数组啊?


kanjipeng
2013-03-18, 19:46
>> a=[1 1 0 0 0
1 1 0 0 0
0 0 0 1 1
0 0 0 1 1];
b=bwlabel(a,4);
regionprops(b)

ans =

2x1 struct array with fields:
Area
Centroid
BoundingBox

>>

ChinaSun888
2013-06-07, 09:52
>> a=[1 1 0 0 0
1 1 0 0 0
0 0 0 1 1
0 0 0 1 1];
b=bwlabel(a,4);
regionprops(b)

ans =

2x1 struct array with fields:
Area
Centroid
BoundingBox

>>
regionprops(b)生成的是一个结构数组
如果写成
>> f=regionprops(b)
f =
4x1 struct array with fields:
Area
Centroid
BoundingBox

>> f.Area
ans =
2
ans =
2
ans =
2
ans =
2
>> f.Centroid
ans =
1.5000 1.0000
ans =
6.5000 1.0000
ans =
14.5000 1.0000
ans =
19.5000 1.0000