what does following code in MATLAB means?
L = bwlabel(B,8)
mx= max(max开发者_Python百科(L))
any ideas?
max
takes, by default, the maximum of an array along the first non-singleton dimension. If L
is a 2D array (which it should, given your call to bwlabel
), the first call of max
collapses the first dimension, so that there is only one row with column maxima, and the second call collapses the second dimension, so that there is only a scalar maximum left. In this example, max(max(L))
is equivalent to max(L(:))
Since bwlabel
performs connected component labeling (i.e. labeling each connected group of pixels with unique, sequential integers), mx
tells you the number of groups of pixels in the image.
EDIT
As @gnovice mentions in the comments, the highest label assigned by bwlabel
is returned as its second output argument: [L,mx] = bwlabel(B,8);
bwlabel
returns a 2D matrix of connected components. Nested max()
like that returns the single largest value in a 2D matrix, so, the highest component found.
精彩评论