Display image using RGB values
Afficher commentaires plus anciens
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 commentaire
Raymond MacNeil
le 3 Jan 2020
Modifié(e) : Raymond MacNeil
le 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
Réponses (0)
Catégories
En savoir plus sur Image Category Classification dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!