Nevermind everyone. I got it to work. I set the Dim = 3 and concatenated the image properly. I must of had old data loaded and once I used clear all it worked.
How do I piece together a 2-dim image using 3 given images, each representing R, G, B?
1 回表示 (過去 30 日間)
古いコメントを表示
I was given 3 images, all are 2-dim arrays. One represents R (red), G (green), and B (blue). Each of these are of the same image but representing RGB. I am supposed to create a composite image using those three that are given. What is the best way to do this in Matlab? I read in each image, then I did this:
R = red; %changing variable name G = green;
B = blue;
I_rgb = cat(2,R,G,B);
imagesc(I_rgb)
I tried setting the dim = 3 but Matlab didn't like it because, I assume, the images are all 2-dim. The way I have it, instead of getting back one image, I get back the 3 images side by side.
採用された回答
Joseph Cheng
2017 年 4 月 6 日
you should be using cat(3,red,green,blue) because you want to stack in the 3rd dimension.
x = randi(3,3,3)
x =
3 3 3
1 1 2
3 3 2
cat(3,x,x,x)
your statement "I tried setting the dim = 3 but Matlab didn't like it" doesn't tell us much on why matlab didn't like it. my suspicion is that all 3 are not the same size.
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!