如何将灰度图像转换为全彩色的rgb? [英] How to convert grayscale image to rgb with full colors?

查看:2204
本文介绍了如何将灰度图像转换为全彩色的rgb?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将灰度图像转换为rgb图像。我在网上搜索并找到了这段代码:

I'm trying to convert a grayscale image to rgb image . I searched the net and found this code:

rgbImage = repmat(grayImage,[1 1 3]);
rgbImage = cat(3,grayImage,grayImage,grayImage);

但这样做只是以3-D矩阵给出灰度图像。
我希望有一种方法可以将它转换为真彩色图像。

but what this does is only give the image in gray-scale with 3-D matrix. I want to have a way that i can convert it into true color image.

推荐答案

不可能直接从其灰度版本恢复彩色图像。正如@Luis Mendo在评论中正确地说的那样,所需的信息并没有实际存储在那里。

It's impossible to directly recover a colour image from the grey scale version of it. As correctly said by @Luis Mendo in the comments, the needed information are not physically stored there.

你可以做的是尝试在强度等级和颜色之间进行映射,然后进行插值。然而,这不会产生良好的结果,而只是一些可能与您想要的距离很远的颜色映射信息。

What you can do is try to come up with a mapping between intensity level and colour, then play around with interpolation. This however will not produce a good result, but just some colour mapping information that may be very far from what you want.

如果您有另一个彩色图像并且想要将其颜色与灰度图像相匹配,您可能需要查看: http://blogs.mathworks.com/pick/2012/11 / 25 / conversion-images-from-grayscale-to-color /

特别是引用的函数可以在这里找到: http://www.mathworks.com/matlabcentral/fileexchange/8214-gray-image -to-彩色图像转换#评论

If you have another colour image and you want to fit its colours to your grey scale image, you may want to have a look at: http://blogs.mathworks.com/pick/2012/11/25/converting-images-from-grayscale-to-color/ .
In particular the function that is there cited can be found here: http://www.mathworks.com/matlabcentral/fileexchange/8214-gray-image-to-color-image-conversion#comments.

请记住,这将是缓慢的,不会产生很好的结果,但我认为你不能做更多。

Bare in mind that this will be slow and will not produce a great result, however I don't think you can do much more.

这篇关于如何将灰度图像转换为全彩色的rgb?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆