MATLAB: MATRIX REPRESENTATION OF COLOUR IMAGES

image analysisimage processing

Why are some colour imges represented by 2 dimensional matrix while other colour images are represented by 3 dimensional matrix ?
For example, the file autumn.tif (which comes along with MATLAB tool box) is represented by a 3 dimensional matrix while the file 'canoe.tif' is represented by a 2 dimensional matrix ?
How do I convert a colour image represented by a 3 dimensional matrix into a colour image represented by a 2 dimensional matrix

Best Answer

You are seeing the difference between RGB ("Truecolor") images, which are rows x columns x 3, compared to a Pseudocolor images, which are rows x columns plus a something-by-3 colormap:
[canimg, canmap] = imread('canoe.tif');
size(canmap)
ans =
256 3
In order to get a pseudocolor image displayed in color, you need to activate its colormap:
colormap(canmap);
This is done on your behalf if you ask to imshow('canoe.tif')
Related Question