Legend for Classified image

4 views (last 30 days)
Shoba
Shoba on 7 Sep 2013
Commented: Massimo Zanetti on 14 May 2021
I have classified LISS 3 imagery using maximum likelihood method. I want to include legend for this classified output. Totally i classified 5 groups. how can i add legend for this output?
I have tried get(gca,'children') option but the legend was empty.
Kindly help me in this regard.
Warm regards Shoba
  2 Comments
Sukuchha
Sukuchha on 16 Sep 2013
Edited: Sukuchha on 16 Sep 2013
if you have mapping toolbox then you can use lcolorbar function.
example from help: figure; colormap(jet(5)) labels = {'apples','oranges','grapes','peachs','melons'}; lcolorbar(labels,'fontweight','bold');
Massimo Zanetti
Massimo Zanetti on 14 May 2021
This is the best answer, didn't know about the labeled colorbar.
Many thanks.

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 7 Sep 2013
Use text() to write out a text string in the color of the class in the image. For example, if class 1 is shown in red, then
text(column, row, 'Class 1 is red', 'Color', [1, 0, 0], 'FontSize', 24);
Of course you need to specify what row and column you want to place the upper left (or is it upper right) of your text string. Do similar code for the other classes/colors.
  4 Comments
Shoba
Shoba on 13 Sep 2013
thank you so much...
Image Analyst
Image Analyst on 13 Sep 2013
Please mark as Accepted if we're done. Thanks.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!