MATLAB: Merge RGB image and grayscale image MATLAB

grayscale imagergb image

Hi Guys. I have a grayscale image with size of 256*256. Pixels are shown in black, white,gray. Now I want to make the center pixel to red, but other pixels remain the same to before. Anybody can help me?
Thanks a lot.

Best Answer

rgbimage = repmat(yourgrayimage, [1 1 3]);
rgbimage(floor(end/2), floor(end/2), :) = [1 0 0]; %if image is of class double; [255 0 0] if uint8