How to convert gray image to rgb image after filtering?

36 Ansichten (letzte 30 Tage)
RGB = imread('peppers.png');
imshow(RGB)
I = rgb2gray(RGB);
figure
imshow(I)

Akzeptierte Antwort

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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (3)

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

Melden Sie sich an, um zu kommentieren.


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

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

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by