How to convert gray image to rgb image after filtering?

33 visualizaciones (últimos 30 días)
RGB = imread('peppers.png');
imshow(RGB)
I = rgb2gray(RGB);
figure
imshow(I)

Respuesta aceptada

Gopichandh Danala
Gopichandh Danala el 2 de Feb. de 2017
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 comentarios
shaik sabeha
shaik sabeha el 3 de Feb. de 2017
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 el 3 de Feb. de 2017
Editada: Gopichandh Danala el 3 de Feb. de 2017
post your codes and images so we can check it. Call me Gopi btw, i am a student too..

Iniciar sesión para comentar.

Más respuestas (3)

KSSV
KSSV el 2 de Feb. de 2017
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)
  1 comentario
shaik sabeha
shaik sabeha el 2 de Feb. de 2017
Thank you sir.. but i want the real color as it was, before changing to gray

Iniciar sesión para comentar.


shaik sabeha
shaik sabeha el 3 de Feb. de 2017
Iam not getting the filtered colour image even after filtering, instead ,getting the coloured noisy image.

Image Analyst
Image Analyst el 3 de Feb. de 2017
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 comentarios
shaik sabeha
shaik sabeha el 4 de Feb. de 2017
Sir..it is raising an error at the last line regarding redchannelfiltered line.please help me
Image Analyst
Image Analyst el 4 de Feb. de 2017
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.

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by