MATLAB: How to create a blue color gradient

2554kbluecolorcolor gradientgradientimageimage procesinglinear gradientMATLAB and Simulink Student Suite

Hello, I want to create a 4K image (3840 x 2160 pixels) that has the blue color gradient from 0 to 255, with its 255 levels. Something like this as an example but well done with MATLAB. The goal is to make a linear gradient from 0 to 255 in blue.
Thank you very much in advance.

Best Answer

0 to 255 is 256 values, not 255 values. Anyway, try this:
rows = 3840;
columns = 2160;
black = zeros(rows, columns, 'uint8');
blueRamp = uint8(linspace(0, 255, columns));
% Make into 2-D image.
blueRamp = repmat(blueRamp, [rows, 1]);
rgbImage = cat(3, black, black, blueRamp);
imshow(rgbImage);
Related Question