how to convert a grayscale image to rgb image

2 ビュー (過去 30 日間)
KRISHNA MOORTHY
KRISHNA MOORTHY 2012 年 4 月 18 日
回答済み: DGM 2023 年 12 月 29 日
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:

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by