Matlab can use 3 different types of data and 4 different formats to store images. The 3 types of data are:
Numbers are encoded as unsigned integers in 8 bits. Possible values range between 0 and 255. This is the most cost-effective format in terms of memory space, but it does not allow algebraic operations.
Numbers are encoded as unsigned integers in 16 bits. Possible values range between 0 and 65535. This format is similar to uint8 but offers a wider range of values. It is rarely used.
Numbers are encoded as double-precision floating-point values, in 64 bits. Every possible real value can be encoded, within the precision limits. This format is the less cost-effective, but allows all algebraic operations
The 4 image formats are:
The image is stored in a 2D matrix whose coefficients are indexes pointing towards an associated color table (colormap). With data types uint8 or uint16, a value of 0 corresponds to the first row of the colormap, 1 corresponds to the second row, and so on. With data type double, a value of 1.0 corresponds to the fist row, 2 to the second, and so on.
The image is stored in a 3D matrix of size (m, n, 3). The third dimension gives the RGB decomposition of the pixel color.
The image is stored in a 2D matrix whose coefficients correspond to gray levels.
The image is stored in a 2D matrix, which takes only 0 and 1 values (black and white, resp.). Only data types uint8 or double are allowed with this image format.
A colormap is the color table associated with an indexed image. This matrix contains m rows and 3 columns of elements of data type double. Each row gives the RGB decomposition of a color. The coefficients must fall into the interval [0:0; 1:0].