how to convert a grayscale image to rgb image

20 次查看(过去 30 天)
how to covert a grayscale image to rgb image

回答(3 个)

Walter Roberson
Walter Roberson 2012-4-18
cat(3, YourImage, YourImage, YourImage)
The result will be a truecolor image that happens to only use gray tones.
  2 个评论
amir
amir 2012-8-22
移动:DGM 2023-12-29
Dear Walter could you please clarify the process? i didn't get how to execute the commend? many thanks
Walter Roberson
Walter Roberson 2012-8-22
移动:DGM 2023-12-29
For example:
YourImage = rgb2gray( imread('lena.tif') );
newImage = cat(3, YourImage, YourImage, YourImage);

请先登录,再进行评论。


Image Analyst
Image Analyst 2012-8-22
This should also work:
rgbImage = ind2rgb(grayImage, gray(256));
though I usually use the cat() method given by Walter.
  1 个评论
Walter Roberson
Walter Roberson 2012-8-23
The cat() method will work when the grayscale image is class single or double, or uint8 or uint16, but ind2rgb() requires uint8 or uint16.

请先登录,再进行评论。


DGM
DGM 2023-12-29
This answer covers multiple ways, depending on what your expected results are:

Community Treasure Hunt

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

Start Hunting!

Translated by