How to convert a grayscale matrix to an RGB matrix in MATLAB?
rgbImage = grayImage / max(max(grayImage)); or rgbImage = grayImage / 255; Which of the above is right,and reason? To convert a grayscale image to an RGB image , there are two issues you have to address: Grayscale images are 2-D, while RGB images are 3-D, so you have to replicate the grayscale image data three times and concatenate the three copies along a third dimension. Image data can be stored in many different data types , so you have to convert them accordingly. When stored as a double data type, the image pixel values should be floating point numbers in the range of 0 to 1. When stored