MATLAB: How to change 1 channel image to 3 channel

computer visiondeep learningimage processingImage Processing Toolbox

I have several grayscale images with channel 1, then I want to convert it to RGB channel 3 image, how do I change it?

Best Answer

Try cat() to stack the gray scale image into 3 slices (color channels):
rgbImage = cat(3, grayImage, grayImage, grayImage);
It will be an RGB image though the only colors will be gray since there is no difference between the three different color channels. It will be a 3-D image with the z-direction (third index) being the color channel index.