How to Convert integer numbers to RGB values

4 ビュー (過去 30 日間)
Anupam  Saikia
Anupam Saikia 2019 年 5 月 16 日
回答済み: Sulaymon Eshkabilov 2019 年 5 月 16 日
How can we convert set of 3 separate integer values to equivalent or processable RGB values?

回答 (1 件)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2019 年 5 月 16 日
Hi Anupam,
If you'd like to generate/create RGB values like for images, then it is quite straightforward.
Let's create 25 - by - 25 RGB image values with the uniform random generator or with already existing numerical values.
clearvars
R = randi([0, 1], 25);
G = randi([0, 1], 25);
B = randi([0, 1], 25);
RGB(:,:,1)=R;
RGB(:,:,2)=G;
RGB(:,:,3)=B;
imshow(RGB), shg
%% Or
clearvars
RGB(:,:,1)=randi([0,255], 25);
RGB(:,:,2)=randi([0,255], 25);
RGB(:,:,3)=randi([0,255], 25);
imshow(RGB), shg
Good luck

Community Treasure Hunt

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

Start Hunting!

Translated by