필터 지우기
필터 지우기

How to combine separate label matrix into one

조회 수: 2 (최근 30일)
Aliyu Abdu
Aliyu Abdu 2019년 10월 13일
댓글: Aliyu Abdu 2019년 10월 14일
Hello...
I have three binary masks from which I generated their individual label matrix. But I can't figure out how to combine them into one single label matrix to show the three objects. The code I use for generating the lable matrix is:
L1 = bwlabeln(BW1);
L2 = bwlabeln(BW2);
L3 = bwlabeln(BW3);
L1((L1 > 0)) = 1; L2((L2 > 0)) = 2; L3((L3 > 0)) = 3;
I then use the code below to combine the three label matrix.
L_matrix = (uint8(L1)|uint8(L2)|uint(L3));
figure,imshow(L_matrix)
But the result only shows one object (all ones instead of 1s, 2s, and 3s). Attached are the masks and the resulting L_matrix.
  댓글 수: 2
dpb
dpb 2019년 10월 13일
You're looking for bitor, not logical or which only returns T|F (1|0)
BTW, you missed an '8' in the last cast expression above.
Aliyu Abdu
Aliyu Abdu 2019년 10월 14일
Tried it, and it worked. Thanks!

댓글을 달려면 로그인하십시오.

답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by