필터 지우기
필터 지우기

How to convert gray image to rgb image after filtering?

조회 수: 20 (최근 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.

댓글을 달려면 로그인하십시오.

카테고리

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