How to create a 2D colorfield with red and green from 0 to 255 and b everywhere 128?

1 回表示 (過去 30 日間)
baxbear
baxbear 2017 年 11 月 29 日
回答済み: Image Analyst 2017 年 11 月 29 日
Hello, can somebody tell me how to do it? I experimented with colormap but couldn't create the expected result.
r = [0:1/255:1]'; g = [0:1/255:1]'; b = repmat(0.5,1,256)';
map = [r,g,b];
cmap = colormap([r, g, b]);
but then only thing I received was an empty figure window :/
Can you help me?

回答 (1 件)

Image Analyst
Image Analyst 2017 年 11 月 29 日
Try this:
rows = 480;
columns = 640;
red = uint8(linspace(0, 255, rows*columns));
red = reshape(red, rows, columns);
green = red;
blue = 128 * ones(rows, columns, 'uint8');
rgbImage = cat(3, red, green, blue);
imshow(rgbImage);

カテゴリ

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