how to converty gray image to color image?

3 次查看(过去 30 天)
how to converty gray image to color image?

回答(1 个)

Image Analyst
Image Analyst 2012-9-25
Depending on what you want the gray to be....
grayImage = rgb2gray(rgbImage);
OR
grayImage = rgbImage(:, :, 1); % Extract red channel.
grayImage = rgbImage(:, :, 2); % Extract green channel.
grayImage = rgbImage(:, :, 3); % Extract blue channel.
  4 个评论
Ryan
Ryan 2012-9-25
To build on Matt's answer, here is a reference for colormaps in Matlab: http://www.mathworks.com/help/matlab/ref/colormap.html
Image Analyst
Image Analyst 2012-9-25
Sorry. I didn't notice, since this is much much less common than the other way. You can use cat() or ind2rgb():
rgbImage = cat(3, grayImage, grayImage, grayImage);
rgbImage = ind2rgb(grayImage, cmap); % e.g. cmap = gray(256)

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Red 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by