功能:标注二进制图像中已连接的部分。 其中BW为输入图像;N可取值为4或8表示连接四连通或八连通区域;NUM为找到的连通区域数目;L为输出图像矩阵,其元素值为整数,背景被标记为0,第一个连通区域被标记为1,第二个连通区域被标记为2,依此类推.所以你不明白的1,2,3即为第1,2,3个连通区域的标记 网上给出的解释大部分是不完整的, 官网的解释 L = bwlabel(BW, n) returns a matrix L, of the same size as BW, containing labels for the connected objects in BW. The variable n can have a value of either 4 or 8, where 4 specifies 4-connected objects and 8 specifies 8-connected objects. If the argument is omitted, it defaults to 8. The elements of L are integer values greater than or equal to 0. The pixels labeled 0 are the background. The pixels labeled 1 make up one object; the pixels labeled 2 make up a second object; and so on. 相信大家看了,都头晕的。现在我给出列子,大家可以更加理解的: (1): A=[0 1 1 0 1 0 1 0 1 1 0 0 0 1 0 1 1 0 1 0 1]; [L,M]=bwlabel(A,4); 此时L=[0 1 1 0 2 0 4 (2): A=[0 1 1 0 0 0 1 0 1 1 0 0 0 1 0 1 1 0 0 0 1]; [L,M]=bwlabel(A,4); L=[0 1 1 0 0 0 2 (3): A=[0 1 1 0 0 0 1 0 1 1 0 0 0 1 0 1 1 0 1 0 1]; [L,M]=bwlabel(A,4); L=[0 1 1 0 0 0 3 大家看我A中1的位置就应该明白什么意思了吧 !! 其实大家可以这样理解的:四连通区域是这样的: 1 看懂这些,相信大家都不陌生了。哈哈哈 ~~~其实我刚开始的时候也走了不少弯路的,分享出来大家可以少走弯路的,嘻嘻,不过还是要自己认真的思考的~~~~~~ |
|