IMAGE PROCESSING TOOLBOX
The Image Processing Toolbox extends the basic capabilities of Matlab by providing a number of specialized I/O, display, and processing functions for images and image processing. Type "help images" at the Matlab prompt to get a listing of the functions available.
An image is stored as a matrix using standard Matlab matrix conventions. There are five basic types of images supported by Matlab:
The Image Processing Toolbox provides functions imread and imwrite that will read and write several standard image types. Type "help imread" and "help imwrite" to get more information.
To set the default colormap, use colormap. Ordinarily, you should use the colormap gray(256) for 8-bit grayscale images. Use imshow(X) to display images after setting a default colormap. See the help on imshow for other usages. To force the window to make one screen pixel the same size as one image pixel, use truesize. You can display multiple images by either creating multiple figures with the figure command or by putting multiple images in the same figure with the subplot command.
ADVANCED IMAGE PROCESSING
Sometimes it is convenient to represent an image as a vector rather than
as a matrix. If I is an image in matrix form,
Iv = I(:);
will create a vector Iv whose entries are the stacked columns of I. To stack rows, type
It = I'; Iv = It(:);
To return a vector to matrix form, use reshape.
If you want to divide an image into blocks and process each block individually, you can use the function blkproc. This function will allow you to process distinct blocks as well as overlapping blocks. With a little creativity, this function can be used to eliminate many loops that would otherwise be necessary. Some related functions are im2col, col2iml, and colfilt.
There are a number of functions that take other functions as arguments and apply them in a specific way to an image. See blkproc, nlfilter, colfilt, and mfilter2 for details.
Matlab 5.0 allows you to create and manipulate N-dimensional arrays. In
most cases, the syntax is a straightforward extension of matrix syntax.
For example, to create a 3x3x2 array of ones, use
x = ones(3,3,2);