The MATLAB help for imread says:
A = imread(filename, fmt)
The return value A is an array containing the image data. If the file contains a grayscale image, A is an M-by-N array. If the file contains a truecolor image, A is an M-by-N-by-3 array.
I thought it would generate 3 matrices for the RGB (one with the Red, one with the Green and one with the Blue), so I did:
img = imread('myimg')
size(img) % ans = 720 960 3
imshow(img) % the original image
imshow(img(:,:,1)) % print grayscaled image
imshow(img(:,:,2)) % print grayscaled image
imshow(img(:,:,3)) % print grayscaled image
And, as commented, the 3 images are just the original but grayscaled. So, why are 3 images generated?
(using Matlab R2011b)
imshowcommands are essentially given $2$-dimensional arrays, therefore these are shown in grayscale, I suppose. – ccorn Oct 19 '13 at 20:18img(:,:,4)=zeros(size(img(:,:,1)));imshow(img(:,:,[1,4,4]));imshow(img(:,:,[4,2,4]));imshow(img(:,:,[4,4,3])). I suppose that this would plot R in red, G in green, B in blue. – ccorn Oct 19 '13 at 20:26