Representing the result in grayscale

I'm working with this script. The issue is that the result is coloured and I want it in grayscale, but couldn't figure what to change in the script to do that. Do you know what changes I should perform to get the result as grayscale?
Thanks.

 採用された回答

Image Analyst
Image Analyst 2013 年 11 月 12 日

1 投票

L is the output of the classification. It's a monochrome image. Just use that and not Lrgb which he just created to make the classification regions colorful. So you already have what you want, which is the L array. There is nothing else you need to do.

3 件のコメント

med-sweng
med-sweng 2013 年 11 月 12 日
Thanks for your nice answer. When I display "L", I get a black screen. Is there something I should add in order to obtain the required result?
Image Analyst
Image Analyst 2013 年 11 月 12 日
編集済み: Image Analyst 2013 年 11 月 12 日
That's because it has values of only 0, 1, or 2 due to there being 3 classes. So it looks too dark to see when the max range is 255. To increase the contrast, use []:
imshow(L, []);
0 will stay 0, 1 will map to 128, and 2 will be 255.
med-sweng
med-sweng 2013 年 11 月 13 日
Yes, you are absolutely right. Thanks a lot

サインインしてコメントする。

その他の回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 11 月 12 日
編集済み: Azzi Abdelmalek 2013 年 11 月 12 日

0 投票

Use rgb2gray function

1 件のコメント

med-sweng
med-sweng 2013 年 11 月 12 日
Thanks for your reply. When I got the result, I made a "cut" of the result and used rgb2gray for converting the image to grayscale. But, somehow I felt that the result is not as expected. So, thought if this could be made within the script mentioned?

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeFuzzy Logic Toolbox についてさらに検索

質問済み:

2013 年 11 月 12 日

コメント済み:

2013 年 11 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by