How to convert gray image to rgb image after filtering?

20 次查看(过去 30 天)
RGB = imread('peppers.png');
imshow(RGB)
I = rgb2gray(RGB);
figure
imshow(I)

采纳的回答

Gopichandh Danala
I know my answer might sound like beating around the bush which makes no sense but I think this is what you are asking. I assume you want to know about different color channels if so this is the answer.
% Get back original color RGB image
RGB = imread('peppers.png');
figure, imshow(RGB,[])
channel1 = RGB(:,:,1);
channel2 = RGB(:,:,2);
channel3 = RGB(:,:,3);
grayImg = rgb2gray(RGB);
figure, imshow(grayImg)
actualImg = cat(3,channel1,channel2,channel3);
figure, imshow(actualImg)
But in reality, If u don't have the RGB saved for later use, You cannot retrieve the exact original color image from the converted grayscale image
what i meant to say is:
grayImg = rgb2gray(RGB);
figure, imshow(grayImg)
if this is the only current information available for you and no access to RGB, you cannot get back actual color image
Let me know if this is what you are trying.
Gopi
  3 个评论
shaik sabeha
shaik sabeha 2017-2-3
Sir i have taken a noisy colour image, converted it to gray and then applied filter on it,but after filtering im not getting the filtered colour image, instead, getting a noised colour image itself...
Gopichandh Danala
编辑:Gopichandh Danala 2017-2-3
post your codes and images so we can check it. Call me Gopi btw, i am a student too..

请先登录,再进行评论。

更多回答(3 个)

KSSV
KSSV 2017-2-2
If you have a colormap, you can convert your grayimage to RGB.
RGB = imread('peppers.png');
imshow(RGB)
I = rgb2gray(RGB);
figure
imshow(I)
cmap = jet ;
Irgb = ind2rgb(I, cmap);
figure ; imshow(Irgb)

shaik sabeha
shaik sabeha 2017-2-3
Iam not getting the filtered colour image even after filtering, instead ,getting the coloured noisy image.

Image Analyst
Image Analyst 2017-2-3
You are not getting the filtered color image because you did not filter the color image -- you filtered a gray scale copy of it. If you want to filter the image you need to decide where the noise is. Is it just the brightness that has noise? Or do the colors/hues also have noise? You can either extract the color channels and filter each one independently and the reassemble them:
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
% Insert filtering code here.
% Recombine separate color channels into a single, true color RGB image.
rgbImage = cat(3, redChannelFiltered, greenChannelFiltered, blueChannelFiltered);
or else convert to HSV or LAB color space, filter the appropriate channel, and then reassemble. Or you can look for more sophisticated noise reduction methods that were designed with colored images in mind.. Search the literature here in VisionBib
  3 个评论
shaik sabeha
shaik sabeha 2017-2-4
Sir..it is raising an error at the last line regarding redchannelfiltered line.please help me
Image Analyst
Image Analyst 2017-2-4
You forgot to include the code where you create redChannelFiltered. Where is your filtration code that goes in between the color channel extraction, and the rebuilding of the RGB image from the component color channels? You forgot to include it, or call it, or both.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Get Started with Image Processing Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by