Display image using RGB values
조회 수: 6 (최근 30일)
이전 댓글 표시
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
Raymond MacNeil
2020년 1월 3일
편집: Raymond MacNeil
2020년 1월 3일
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
답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!