Search code examples
matlabcolorsimage-manipulationgrayscale

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?


Solution

  • Use rgb2gray to strip hue and saturation (ie, convert to grayscale). Documentation