开发者

what does max(max(L)) in MATLAB means?

开发者 https://www.devze.com 2023-01-27 07:33 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号