Mutilspectral image to RGB

 Accepted 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

1 Comment

Note that rescaling can be done with rescale() in current versions of MATLAB, or with the deceptively named mat2gray() in older versions.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!