creating a color block inside a colormap? - homework

3 ビュー (過去 30 日間)
Nora
Nora 2013 年 11 月 17 日
コメント済み: Nora 2013 年 11 月 18 日
For one part I need to create two 3 x 3 matrices and use subplot to display a colormap that shows a single color box/rectangle in the middle of the colormap. The two would have different colors.
For example, one would be completely blue except of a red square in the center of the color map. The second one could be light blue, with the red block in the center. ???

採用された回答

Image Analyst
Image Analyst 2013 年 11 月 18 日
Try this:
matrix1 = [0,0,0;0,1,0;0,0,0]
matrix2 = [2,2,2;2,1,2;2,2,2]
subplot(1,2,1);
imshow(matrix1, [0,2], 'InitialMagnification', 1000);
myColorMap = [0,0,1;... % Blue
1,0,0;... % Red
.5, .5, 1] % Light blue.
colorbar;
subplot(1,2,2);
imshow(matrix2, [0,2], 'InitialMagnification', 1000);
myColorMap = [0,0,1;... % Blue
1,0,0;... % Red
.5, .5, 1] % Light blue.
colormap(myColorMap);
colorbar;
  1 件のコメント
Nora
Nora 2013 年 11 月 18 日
Yes that helped. Thank you!

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

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2013 年 11 月 17 日
colormaps are N x 3 vectors, with N being the number of colors and 3 representing RGB. The only way they could be square would be if you only had 3 colors. A colormap does not have colors within it: it gives the information about what RGB corresponds to which color number.

カテゴリ

Help Center および File ExchangeColormaps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by