You cannot convert grayscale images back to rgb without loss of information. Many different combinations of RGB values convert to the same grayscale level, so if all you have at a location is the grayscale level, then you cannot know which of the 65536 RGB values that map to the exact same grayscale that the RGB came from.
You can convert RGB to pseudocolor (ind). You could save a copy of the map used for that. You could convert each member of the pseudocolor map into grayscale and display it that way, and later you could convert back the pseudocolor map into RGB. However, if you want to do anything that modifies the grayscale (such as adaptive equalization) then you will have trouble.
[indimg, indmap] = rgb2ind(YourImage);
indasgray = rgb2gray(reshape(indmap,[size(indmap,1),1,3]));
image(indimg);
colromap(indasgray);
ReconstructedImage = ind2rgb(indimg, indmap);
Best Answer