Image Processing Toolbox Previous page   Next Page

Reading a Graphics Image

The imread function reads an image from any supported graphics image file format, in any of the supported bit depths. Most image file formats use 8 bits to store pixel values. When these are read into memory, MATLAB stores them as class uint8. For file formats that support 16-bit data, PNG and TIFF, MATLAB stores the images as class uint16.

For example, this code reads an RGB image into the MATLAB workspace as the variable RGB.

In this example, imread infers the file format to use from the contents of the file. You can also specify the file format as an argument to imread. MATLAB supports many common graphics file formats, such as Microsoft Windows Bitmap (BMP), Graphics Interchange Format (GIF), Joint Photographic Experts Group (JPEG), Portable Network Graphics (PNG), and Tagged Image File Format (TIFF) formats. For the latest information concerning the bit depths and/or image formats supported, see the reference page for the imread function.

Reading Multiple Images from a Graphics File

MATLAB supports several graphics file formats, such as HDF and TIFF, that can contain multiple images. By default, imread imports only the first image from a file. To import additional images from the file, use the syntax supported by the file format.

For example when used with TIFF files, you can use an index value with imread that identifies the image in the file you want to import. This example reads a series of 27 images from a TIFF file and stores the images in a four-dimensional array. You can use imfinfo to determine how many images are stored in the file.

When a file contains multiple images that are related in some way, such as a time sequence, you can store the images in MATLAB as a 4-D array. All the images must be the same size. For more information, see Multiframe Image Arrays.


Previous page  Reading and Writing Image Data Writing a Graphics Image 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