How do I assign a range of values in an array to specific colors?

2 ビュー (過去 30 日間)
GS
GS 2016 年 4 月 16 日
回答済み: Walter Roberson 2016 年 4 月 16 日
I have extracted a 2-D matrix from a RGB 3-D matrix. The values in this 2-D matrix range from 0 - 10,000. I would like for certain ranges to display certain colors, for example i'd like for values from 0 to 100 to be displayed as purple and values from 101-200 to be displayed as pink. Is their a way I can assign different ranges to different colors?

回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 4 月 16 日
Create a colormap with 10001 entries in it. In entries 1 to 101, write the RGB for purple. In entries 102 to 201, write the codes for pink.
image() your data. colormap() your created colormap. caxis([0 10000]) Now each value will map to colormap index 1 + floor(value)

カテゴリ

Help Center および File ExchangeColor and Styling についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by