label2rgb() and custom color assigment

조회 수: 6 (최근 30일)
Dimitris M
Dimitris M 2012년 6월 11일
댓글: Veena Chatti 2020년 10월 5일
Hello
I have a question concerning the label2rgb () function. I have used the decision tree classifier and I have come up with the classification result of a dataset. I would like to know to use the label2rgb() to assign specific colors to each labeled element. I have seen the examples contained in the label2rgb function but does not point out how can be used to assign specific colors to each label (except the background ).
Can you please give me a hint how this can be make ?
Thank you in advance.

답변 (2개)

Sean de Wolski
Sean de Wolski 2012년 6월 11일
Feed it an nx3 map of colors you want with each row of the map corresponding to that label, e.g:
x = [1 0 2];
label2rgb(x,[0.1 0.17 0.67;0.3 0.49 0.72])

Dimitris M
Dimitris M 2012년 6월 11일
Thank you for the quick reply. The problem is that I have many classification results and I would like to keep the same colormap in each case. The label matrix is created randomly (i think) based on the regions each one of my Images has. Can I somehow assign a specific color for a specific class using a cell matrix (cell matrix contains string names of classes). I was able to do this connection I could have always have a certain color for each class object, eg. Buildings---> always red.
Thank you
  댓글 수: 1
Veena Chatti
Veena Chatti 2020년 10월 5일
Hi, did you ever figure this out? I'm trying to do something similar and was hoping there are some solutions already out there I can try.

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

Community Treasure Hunt

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

Start Hunting!

Translated by