Reputation: 95948
I know how to do the opposite rgb2gray(img)
but I can't find a function gray2rgb(img)
that can convert from grayscale to truecolor.
Is there another function that can do this?
Upvotes: 0
Views: 2355
Reputation: 40982
nice function made by Gabriel Frangakis:
function [Image]=gray2rgb(Image)
%Gives a grayscale image an extra dimension
%in order to use color within it
[m n]=size(Image);
rgb=zeros(m,n,3);
rgb(:,:,1)=Image;
rgb(:,:,2)=rgb(:,:,1);
rgb(:,:,3)=rgb(:,:,1);
Image=rgb/255;
end
you should make the gray value for each coordinate RGB
Upvotes: 2