I converted an RGB image (which is in double format) to a gray scale image of the same format using rgb2gray in Matlab. Now I want to convert the same image from gray to RGB. I used gray2rgb in Matlab but it’s giving an error. So how can we convert a grayscale image to an RGB image using Matlab?
I converted an RGB image (which is in double format) to a gray scale
Share
I’m sorry to say it’s not possible.
By converting the image to grayscale you’ve reduced the amount of information (3 dimensions at each pixel down to 1) and this can’t be recovered.
The
rgb2grayfunction is one included in Matlab and works fine.The
gray2rgbfunction is not a standard Matlab function. If you are referring to this function on Matlab central, it’s documentation states it doesn’t do anything useful but just creates a 3d matrix from the 1d matrix; the image will still be grayscale.