MATLAB: How can i check if an image is RGB or grayscale or binary

checkimagetypes

I'm a new in matlab, need answer to this question.. And, may i change the size of matrix of RGB image to two-dimensional matrix? I wanna try edge detection, i load an grayscale image but the image matrix show an image have three-dimensional matrix.. Any solutions?? Thank you for your response..

Best Answer

You can convert to grayscale using a combination of all color channels:
grayImage = rgb2gray(rgbImage);
Or you can extract one of the color channels:
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
You can get the size (dimensions) like this:
[rows columns numberOfColorChannels] = size(yourImageArray);