Image Processing Toolbox Previous page   Next Page

Working with Images in MATLAB

Images are most commonly stored in MATLAB using the logical, uint8, uint16 and double data types. You can perform many standard MATLAB array manipulations on uint8 and uint16 image data, including

Certain MATLAB functions, including the find, all, any, conv2, convn, fft2, fftn, and sum functions, accept uint8 or uint16 data but return data in double-precision format.

The basic MATLAB arithmetic operators, however, do not accept uint8 or uint16 data. For example, if you attempt to add two uint8 images, A and B, you get an error, such as

Because these arithmetic operations are an important part of many image-processing operations, the Image Processing Toolbox includes functions that support these operations on uint8 and uint16 data, as well as the other numeric data types. See Image Arithmetic for more information.

Storage Classes in the Toolbox

By default, MATLAB stores most data in arrays of class double. The data in these arrays is stored as double-precision (64-bit) floating-point numbers. All MATLAB functions work with these arrays.

For image processing, however, this data representation is not always ideal. The number of pixels in an image can be very large; for example, a 1000-by-1000 image has a million pixels. Since each pixel is represented by at least one array element, this image would require about 8 megabytes of memory.

To reduce memory requirements, MATLAB supports storing image data in arrays as 8-bit or 16-bit unsigned integers, class uint8 and uint16. These arrays require one eighth or one fourth as much memory as double arrays.


Previous page  Images in MATLAB and the Image Processing Toolbox Image Types in the Toolbox Next page

Learn more about the latest releases of MathWorks products:

 © 1994-2009 The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS