フィルターのクリア

convert grayscale to rgb

5 ビュー (過去 30 日間)
evangeline
evangeline 2014 年 1 月 22 日
回答済み: DGM 2022 年 4 月 19 日
I want to convert a grayscale image to rgb, but I don't want to use the gray2rgb command, I know that the input matrix is 2D, but the output image should be 3D, but I just don't know how to do it.. I dont know how to map the 2D matrix values to 3D matrix values...

採用された回答

Walter Roberson
Walter Roberson 2014 年 1 月 22 日
rgbimage = grayimage(:,:,[1 1 1]);
  3 件のコメント
evangeline
evangeline 2014 年 1 月 22 日
thank you so much, I just have another question, I want to check each pixel of the 2D matrix, and switch-case the value, like if its between 1 and 50 , give a specific color to it in the 3D matrix according to the that pixel value, how can I do this mapping? I want to determine the r and g and b values of the color in output matrix myself, now how can I do this with rgbimage = grayimage(:,:,[1 1 1]); ?
Walter Roberson
Walter Roberson 2014 年 1 月 22 日
grayslice (second form, supplying a vector of values), followed by ind2rgb() to do the conversion to an RGB image.

サインインしてコメントする。

その他の回答 (1 件)

DGM
DGM 2022 年 4 月 19 日
Depending on what the goals are, there are various ways to interpret the question. The following link includes demonstrations of converting a single-channel image to a 3-channel image via:
  • channel replication (like above)
  • channel filling/deletion and potential hue adjustment
  • uniform and nonuniform colorization methods
  • color mapping
I imagine most needs are met with replication or colormapping, but I like generalizable answers to be somewhat comprehensive.

カテゴリ

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