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

2 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Colormaps 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by