| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
| On this page… |
|---|
Two-dimensional arrays can be displayed as images, where the array elements determine brightness or color of the images. For example, the statements
load durer whos Name Size Bytes Class X 648x509 2638656 double array caption 2x28 112 char array map 128x3 3072 double array
load the file durer.mat, adding three variables to the workspace. The matrix X is a 648-by-509 matrix and map is a 128-by-3 matrix that is the colormap for this image.
MAT-files, such as durer.mat, are binary files that can be created on one platform and later read by the MATLAB software on a different platform.
The elements of X are integers between 1 and 128, which serve as indices into the colormap, map. Then
image(X) colormap(map) axis image
reproduces Albrecht Dürer's etching shown in Matrices and Magic Squares. A high-resolution scan of the magic square in the upper-right corner is available in another file. Type
load detail
and then use the up arrow key on your keyboard to reexecute the image, colormap, and axis commands. The statement
colormap(hot)
adds some 21st century colorization to the 16th century etching. The function hot generates a colormap containing shades of reds, oranges, and yellows. Typically, a given image matrix has a specific colormap associated with it. See the colormap reference page for a list of other predefined colormaps.
You can read standard image files (TIFF, JPEG, BMP, etc using the imread function. The type of data returned by imread depends on the type of image you are reading.
You can write MATLAB data to a variety of standard image formats using the imwrite function. See the MATLAB reference pages for these functions for more information and examples.
For More Information See Displaying Bit-Mapped Images in the MATLAB Graphics documentation for details about MATLAB image processing capabilities. |
![]() | Creating Mesh and Surface Plots | Printing Graphics | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |