MATLAB: Mutilspectral image to RGB

colormapmulti-spectralrgb

I would like to convert the attached multispectral images to RGB in matlab. Please help with the code.

Best Answer

To simply put each image into one of the R, G or B-layers of an RGB-image just do this:
img = peaks(12); % just something to give
img1 = img; % us three different
img2 = img1*0.7; % images with different
img3 = img2*0.7; % intensities
C1 = 1; % Possible
C2 = 1; % intensity
C3 = 1; % scaling-factors
rgbimg = cat(3,img1*C1,img2*C2,img3*C3);
Now matlab expects RGB-images in double format to be between 0 and 1 to display them with functions like imagesc, so you might want to rescale rgbimg:
rgbimg = (rgbimg - min(rgbimg(:)))/(max(rgbimg(:)) - min(rgbimg(:)));
HTH