How can I count patterns in matrices

I would like to kow whether there is a way of counting the number of continous patterns in a binary matrix.
0 1 0 0 1 0 0
0 1 0 0 1 0 1
1 1 0 1 1 0 1
0 1 0 1 0 0 1
0 1 0 1 1 0 0
0 0 0 0 1 1 1
0 0 0 0 0 0 0
From the above matrix there are three sets of 1's that join up. How can I caount these rather than just the total number of 1's?

1 件のコメント

Thomas
Thomas 2012 年 9 月 17 日
Could you please define "sets of 1's". If you mean more than 1, then there are 4 sets
1 1 0 1 1 0 1 - 2 sets
0 1 0 1 1 0 0 - 1 set
0 0 0 0 1 1 1 - 1 set

サインインしてコメントする。

回答 (1 件)

José-Luis
José-Luis 2012 年 9 月 17 日
編集済み: José-Luis 2012 年 9 月 17 日

0 投票

There is a built in function for that, that allows you to specify a connectivity pattern:
doc bwconncomp

カテゴリ

ヘルプ センター および File ExchangeOperating on Diagonal Matrices についてさらに検索

タグ

質問済み:

2012 年 9 月 17 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by