How can I convert a color image to grayscale in 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? I'm reading it with: x = imread('bla.jpg'); 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? 回答1: Use rgb2gray to strip hue and saturation (ie, convert to grayscale).