user3607620
user3607620

Reputation: 11

Sorting the connected component in order

I have a question in sort of connected component. I have a binary image ( onlye 0 and 1) I run the function from matlab: f=

1   0   0   1   0   0   0   1   0   0
1   1   0   1   1   1   0   0   1   0
0   0   0   0   0   0   0   1   1   1
1   0   0   0   1   0   1   0   1   1
1   1   0   0   0   0   0   1   1   1
0   0   0   1   0   0   1   0   0   0
0   0   0   1   0   1   1   0   1   1
1   1   0   0   1   0   0   0   1   0
1   1   0   1   1   1   0   1   0   0
1   1   0   0   1   0   0   0   1   0

[L num]=bwlabel(f);

suppose that they give me the ma trix:

1   0   0   4   0   0   0   5   0   0
1   1   0   4   4   4   0   0   5   0
0   0   0   0   0   0   0   5   5   5
2   0   0   0   6   0   5   0   5   5
2   2   0   0   0   0   0   5   5   5
0   0   0   5   0   0   5   0   0   0
0   0   0   5   0   5   5   0   7   7
3   3   0   0   5   0   0   0   7   0
3   3   0   5   5   5   0   7   0   0
3   3   0   0   5   0   0   0   7   0

But you can see in this resul, the order of matrix is follow the column. Now I want to change this in to the oder rows, that mean number 4 is 2 , number 5 is 3... so on. The oder is left-> right and top -> down. How can I do that ( the oder of reading )??

Thank you so much

Upvotes: 0

Views: 82

Answers (1)

ASantosRibeiro
ASantosRibeiro

Reputation: 1257

f=f';
[L num]=bwlabel(f);
L=L';

does this solves your problem?

Upvotes: 1

Related Questions