how to convert gray scale image into rgb image?
42 views (last 30 days)
Ahmed A. Selman on 1 Apr 2013
Use colormap types, since you are interested with a colored region of interest, I think any colormap format suffices. Example:
clc % just to clear things up
R=rgb2gray(I); % It is gray now
imwrite(R,y,'rgb.jpg','jpg'); % Re-change it to colored one
Image Analyst on 1 Apr 2013
ug, if your starting image is monochrome, then you cannot determine the original color. You cannot. Not if all you have is the grayscale image. Period.
You can convert a grayscale image into an RGB image using cat():
rgbImage = cat(3, grayImage, grayImage, grayImage);
of course it will look all grayscale even though it is a "true color" RGB image - it's just that all the "colors" are gray. You can apply a pseudocolor lookup table to the gray values, where each gray value gets mapped into some color, to get a multi-colored image, like this:
rgbImage = ind2rgb(grayImage, jet(256));
however the colors are NOT the original colors of the iris as if you had snapped it with a color camera.
Image Analyst on 2 Apr 2013
You ask: "i hav an image of the iris with all extra features like eye lashes n all..i hav to extract only the iris frm tis image. first i select the two circles of the iris..the resultant image is that the coloured part of the iris is converted to gray scale n the rest is blacked out... but i want to get the original colour....is there ne other method to get the colour of the iris?"
Here's how to do it.
% Make a mask from your circle using poly2mask
% xCircle, yCircle are the coordinates of your circle perimeter.
mask = poly2mask(xCircle, yCircle, rows, columns);
% Now mask the image so that only the original RGB part
% inside the circle remains, and outside the circle is set to black.
maskedRgbImage = bsxfun(@times, rgbImage, cast(mask,class(rgbImage)));