How to convert gray image to rgb image after filtering?

16 ビュー (過去 30 日間)
shaik sabeha
shaik sabeha 2017 年 2 月 2 日
コメント済み: Image Analyst 2017 年 2 月 4 日
RGB = imread('peppers.png');
imshow(RGB)
I = rgb2gray(RGB);
figure
imshow(I)

採用された回答

Gopichandh Danala
Gopichandh Danala 2017 年 2 月 2 日
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 日
編集済み: 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)
  1 件のコメント
shaik sabeha
shaik sabeha 2017 年 2 月 2 日
Thank you sir.. but i want the real color as it was, before changing to gray

サインインしてコメントする。


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.

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by