how to convert a true colour image into rgb image

% code
clc
clear all
close all
w=fspecial('laplacian',0);
f=imread('ee.jpg');
figure
imshow(f)
title('original image');
g1=imfilter(f,w,'replicate');
figure
imshow(g1,[]);
title('unit8 image');
%[f2,revertclass]=tofloat(f);
f2=single(f);
g2=imfilter(f2,w,'replicate');
figure
imshow(g2,[]);
title('double image');
g=f2-g2;
figure
imshow(g);
title('subtracted image');
now i want the o/p image to be converted to its rgb color space.how can i get it i have used the programe like
% code
res=grs2rgb(g);
figure
imshow(cl);
title('coloured image');
but i am getting errors like
% code
Subscript indices must either be real positive
integers or logicals.
Error in ==> grs2rgb at 66 r(:) = map(ci,1);
Error in ==> page77 at 24 res=grs2rgb(g);
so please help in this . the image at the figure3 is present at the https://www.yousendit.com/download/UVJoeFVhZy9PSHhBSXRVag u can see that

 Risposta accettata

Image Analyst
Image Analyst il 21 Mar 2013
You're doing a DOG (difference of Gaussians) filter. You convert two images to floating point and subtract them. MATLAB does not display floating point RGB images. There is no need for the grs2rgb() function. You can either cast it (your "g" variable) to uint8 with the uint8() function, or scale it to the 0-1 range with im2double().

6 Commenti

jagannath mishra
jagannath mishra il 22 Mar 2013
Modificato: Image Analyst il 22 Mar 2013
sir make the image double and got a result.but it don't seems to a coloured one.what to do the image u can see in
I ca't tell what that image is. Try uploading just the image only to tinypic.com or snag.gy.
jagannath mishra
jagannath mishra il 26 Mar 2013
Modificato: jagannath mishra il 26 Mar 2013
sir if i cast my "g" as im2double then also that image is only a true colour image but what i want is an colored image as the original one.now after converting image to the double and then i use the grs2rgb() and what i get is in the "url =http://tinypic.com/r/35jccuq/6".you can see this image and suggest me to what to do.thank you sir
Looks like a screenshot of three images of random noise. I don't know what you want to do. All you said is that you want to convert from grayscale to RGB, and
rgbImage = cat(3, grayImage, grayImage, grayImage);
will do that. I don't know why you feel you need to use grs2rgb(). Don't use it.
sir,basicaly what is my goal is to remove the rain particles from the image.so i try to find something which will help me to detect and remove rain from the image.so as rain is a high frequency particle so my guide told me to use this code.but i think i don't have a fine result by this .and,now by using the code %rgbImage = cat(3, grayImage, grayImage, grayImage); it is just giving an output as the previous subtracted image which is not a "rgb"image.
It's an RGB image with every color channel being the same. If that's not what you want, then please say exactly what you want to be in the red channel, the green channel, and the blue channel. If they are to be different images in each channel then say what they are, how they are different, where they are supposed to come from, etc. Do you want to do the same filtering on each color channel independently and then combine the results into an RGB image when the filtering is all done?

Accedi per commentare.

Più risposte (1)

Jan
Jan il 21 Mar 2013
grs2rgb is no Matlab function. I guess you mean FEX: grayscale-to-rgb-converter. Then the author is responsible for such questions, but the documentation should clear this also. It looks like this function expects an image with indexed colors, while you provide another format.
Instead of posting the method to create the inputs, it would be much easier to understand, iof you show us the size and type of the variable g, and if it contains integer or floating point values.

1 Commento

i have seen that program before but while i put my image in that it says an error .but it will perfectly work on the images given by it.so don't know what to do

Accedi per commentare.

Categorie

Scopri di più su Display Image in Centro assistenza e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by