Matlab image types
There are several ways of encoding the information in an image.
Black and white images
-
A large matrix whose entries are one of two values will specify a black
and white image. Typical values are 0 and 1. In Matlab, 0 corresponds
to black, 1 to white.
-
Use im2bw to convert to black and white. Aso see thresh.m.
Grayscale or intensity images
-
A grayscale image can be specified by giving a large matrix whose
entries are numbers between 0 and 1, with 0 corresponding, say, to black,
and 1 to white.
-
A black and white image can also be specified by giving a large matrix
with integer entries. The lowest entry corresponds to black, the
highest to white. In Matlab, this matrix would be of class uint8
or uint16.
-
See clown_treesBW.m.
Indexed images (intensity images with colormaps)
-
Given a large matrix A with integer entries ranging from 1 to M,
one can color the (i,j) pixel of the image according to the RGB (red-green-blue)
intensities in row A(i,j) of a colormap matrix map,
which is an M by 3 matrix. The program clown_trees.m
shows examples of indexed images. You can see several colormap matrices
in matlab. They are predefined variables. Type gray, hot, jet,
and hit return to see these matrices.
-
It appears that in Matlab, if you use subplot and imshow, each figure can
have only one colormap at a time. So if you use subplots,
use subimage to show the images instead.
-
I believe that intensities and colormaps are how GIF images are encoded.
They also seem to be used on SGI's, because when you change from one window
to another, the colors can get messed up.
RGB or truecolor images
-
An RGB or truecolor image is specified by telling three matrices,
one for the intensity of red, one for green, one for blue (hence the acronym
RGB). These are the three colors to which the cone cells in our eyes
are sensitive. If you use a magnifying glass, these are the three
colors you see on a TV screen, in very small adjacent rectangles.
-
In Matlab, a matrix can have more than two indices. A(:,:,1)
would refer to the first matrix, the one for red, A(:,:,2) for green,
and A(:,:,3) for blue.
NTSC images
-
This is another way of coding the colormap mentioned above. Instead
of red-green-blue, it uses luminance and a two-dimensional chrominance.
It's still three variables.