如何在MATLAB中将彩色图像转换为灰度图像?
问题描述:
我想在计算机视觉中实现一个算法,我想尝试一组图片。图片都是彩色的,但我不想处理。
I am trying to implement an algorithm in computer vision and I want to try it on a set of pictures. The pictures are all in color, but I don't want to deal with that. I want to convert them to grayscale which is enough for testing the algorithm.
如何将彩色图像转换为灰度图?
How can I convert a color image to grayscale?
我正在阅读它:
x = imread('bla.jpg');
有任何参数我可以添加到 imread
将其读为灰度?在读取之后,是否有任何方式将 x
更改为灰度?
Is there any argument I can add to imread
to read it as grayscale? Is there any way I change x
to grayscale after reading it?
答
使用 rgb2gray
来去除色相和饱和度(即转换为灰度)。 文档
Use rgb2gray
to strip hue and saturation (ie, convert to grayscale). Documentation