Display image using RGB values

10 Ansichten (letzte 30 Tage)
Sheetal Patil
Sheetal Patil am 3 Jan. 2020
Bearbeitet: Raymond MacNeil am 3 Jan. 2020
I have a 45x45 matrix. It has values 0 to 1. I want to assign R,G,B values to each value. Like 0=(0,0,255) and 1=(255,0,0) and the middle values will be accordingly.
And then I want to display the image using those R,G,B values. I am new to matlab so I need some help.
  1 Kommentar
Raymond MacNeil
Raymond MacNeil am 3 Jan. 2020
Bearbeitet: Raymond MacNeil am 3 Jan. 2020
Hi Sheetal:
Red, Green, and Blue channels are read from the first, second, and third 'pages' of a matrix, respectively. Thus, at the very least, you need an M * N * 3 matrix. You can include a fourth 'page' if you want your image to contain an alpha channel.
Here is an example of simple square-wave grating that alternates between red and blue bars. This should get the main idea across:
mata = 255*ones(100,10);
matb = zeros(100,10);
red = cat(3, mata, matb, matb);
blue = cat(3, matb, matb, mata);
rb_sqwv = repmat([red, blue], 5);
img = imshow(rb_sqwv)
Cheers,
Ray

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by