reorder label

3 views (last 30 days)
Cristina
Cristina on 5 Nov 2011
Andrei,
Thank you very much for your answer but when I put it the new made L4 introduces a row with 0 between every rows. How can I eliminate this rows? And if the matrix change of size, Have I that change anythings?
L9 =
1 1 0 0
5 5 0 0
0 5 7 7
0 0 9 11
Lp = zeros(size(L9).*[2 1]); Lp(1:2:end) = L9; Lp = bwlabel(Lp')'; L9(L9~=0)=Lp(Lp~=0); Lp =
1 1 0 0
0 0 0 0
2 2 0 0
0 0 0 0
0 3 3 3
0 0 0 0
0 0 4 4
0 0 0 0

Accepted Answer

Andrei Bobrov
Andrei Bobrov on 5 Nov 2011
L4 = zeros(size(L9).*[2 1]);
L4(1:2:end) = L9;
L4 = bwlabel(L4')';
Lp = L4(any(L4,2),:);

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!