开发者

Combine three grayscale images into RGB with MATLAB

I have three grayscale images where each image repres开发者_StackOverflowents a single channel from a RGB image of 16-bit resolution. I would like to convert them to obtain one single RGB image. I have tried cat and ind2rgb but it is not working. Should we index our grayscale images before using ind2rgb? Is there any other way of doing it?

Thanks


Assuming you have three matrices R,G,B of type int16. If you try

RGB = cat(3,R,G,B);
imshow(RGB)

IMSHOW will complain that: RGB images must be uint8, uint16, single, or double.. In fact if you check the documentation:

A truecolor image can be uint8, uint16, single, or double. An indexed image can be logical, uint8, single, or double. A grayscale image can be logical, uint8, int16, uint16, single, or double. A binary image must be of class logical.

So if you concatenate three int16 grayscale images, and you want to use IMSHOW, you have to convert the resulting truecolor image to something it supports:

imshow( im2double(RGB) )
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜