combining RGB to get a full image

96 次查看(过去 30 天)
image_RGB = cat(2,final_red,final_green,final_blue)
imshow(image_RGB);
can anyone suggest me that this code is correct for combining RGB components for getting full image
as soon as possible

采纳的回答

Image Analyst
Image Analyst 2011-10-23
IMPORTANT NOTE: MATLAB is case sensitive. redchannel is different than redChannel.
It looks like you've taken code I've posted many times and tried to adapt it:
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
% Recombine separate color channels into an RGB image.
rgbImage = cat(3, redChannel, greenChannel, blueChannel);
I call them "channels" because that is the terminology Photoshop uses. You have to change the name of the arrays from redChannel to what yours are called. After you split apart your color channels and reprocessed them you have final_red. This, NOT redChannel, is what you need to use. You also need to not change from dimension 3 (which I had) to dimension 2. So the final code would be
% Recombine separate color channels into an RGB image.
rgbImage = cat(3, final_red,final_green,final_blue);
  8 个评论
Chrissie Nyssen
Chrissie Nyssen 2019-7-1
编辑:Chrissie Nyssen 2019-7-1
It's a 3D image if you are layering the R G B images on top of each other -
imgRGB = cat(3, R, G, B)
imshow (imgRGB)
Srivatsan N
Srivatsan N 2020-7-21
Is there any way to transform the grayscale image to rgb image?

请先登录,再进行评论。

更多回答(2 个)

Wayne King
Wayne King 2011-10-23
Hi, You don't want to concatenate along the column dimension. An RGB image has 3 dimensions. You want to concatenate along the 3rd dimension.
imdata = imread('ngc6543a.jpg');
RC = imdata(:,:,1);
GC = imdata(:,:,2);
BC = imdata(:,:,3);
im = cat(3,RC,GC,BC);
isequal(imdata,im)
imshow(im)
  5 个评论
prem preet
prem preet 2011-10-23
??? Undefined function or variable 'redchannel'.
prem preet
prem preet 2011-10-23
this error occured for all 3 above functions ....
imshow(redchannel);.....
plss rply fast..

请先登录,再进行评论。


tablo tofiq
tablo tofiq 2016-5-6
编辑:Stephen23 2016-5-6
display image in three color red&green&blue
a=imread('autumn.tif');
a1=a;
a1(:,:,2)=0;
a1(:,:,3)=0;
subplot(3,1,1)
imshow(a1)
a2=a;
a2(:,:,1)=0;
a2(:,:,3)=0;
subplot(3,1,2)
imshow(a2)
a3=a;
a3(:,:,1)=0;
a3(:,:,2)=0;
subplot(3,1,3)
imshow(a3)
  1 个评论
Stephen23
Stephen23 2016-5-6
Without three intermediate variables:
b = imread('autumn.tif');
b(:,:,4) = 0;
subplot(3,1,1)
imshow(b(:,:,[1,4,4]))
subplot(3,1,2)
imshow(b(:,:,[4,2,4]))
subplot(3,1,3)
imshow(b(:,:,[4,4,3]))

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Formatting and Annotation 的更多信息

标签

尚未输入任何标签。

Community Treasure Hunt

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

Start Hunting!

Translated by