Graphics | ![]() ![]() |
Reading, Writing, and Querying Graphics Image Files
In its native form, a graphics file format image is not stored as a MATLAB matrix, or even necessarily as a matrix. Most graphics files begin with a header containing format-specific information tags, and continue with bitmap data that can be read as a continuous stream. For this reason, you cannot use the standard MATLAB I/O commands load
and save
to read and write a graphics file format image.
MATLAB provides special functions for reading and writing image data from graphics file formats. To read a graphics file format image use imread
; to write a graphics file format image, use imwrite
; to obtain information about the nature of a graphics file format image, use imfinfo
.
This table gives a clearer picture of which MATLAB commands should be used with which image types.
Procedure
Functions to Use
Load or Save a Matrix as a MAT-file
load
save
Load or Save Graphics File Format Image, e.g. BMP, TIFF
imread
imwrite
Display Any Image Loaded Into MATLAB
image
imagesc
Utilities
imfinfo
ind2rgb
![]() | Summary of Image Types and Numeric Classes | Reading a Graphics Image | ![]() |
© 1994-2005 The MathWorks, Inc.