Extract label colors from label2rgb

조회 수: 4 (최근 30일)
Veena Chatti
Veena Chatti 2020년 10월 5일
편집: Veena Chatti 2020년 10월 6일
Hi!
I'm using label2rgb to label ~200-250 objects with watershed.
Here is my code:
labeledL = label2rgb(L,'turbo', [1 1 1], 'shuffle');
How can I extract the specific colors that were assigned to each object by the watershed? The aim is to get a 250x4 double that contains this information, with one column being the labels, and the three other columns containing the corresponding color values.
I would greatly appreciate your tips! Thanks!

채택된 답변

Veena Chatti
Veena Chatti 2020년 10월 6일
편집: Veena Chatti 2020년 10월 6일
I figured out one way:
colors = NaN(max(LL(:)),4);
for i = 1:max(LL(:)) % LL is my labelmatrix
[r,c] = find(LL==i,1)
colors(i,1) = i;
colors(i,2) = RGB(r,c,1) % RGB contains the colors generated by 'turbo' and 'shuffle'
colors(i,3) = RGB(r,c,2)
colors(i,4) = RGB(r,c,3)
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Colormaps에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by