This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Displaying Image Data

This example shows how to read an RGB image into the workspace and display it. The example then converts the RGB image into a grayscale image and displays it. Finally, the example shows how to combine several individual images into one tiled image (or montage).

Read the Image

The sample file named peppers.png contains an RGB image. Read the image into the workspace using the imread function.

RGB = imread('peppers.png');

Display the Color Image

Display the image data using the imshow function.


Convert to Grayscale

Convert the RGB image to grayscale using the rgb2gray function.

gray = rgb2gray(RGB);

Display the Grayscale Image

Display the grayscale image using the imshow function.


Create a Tiled Image from Multiple Images

Combine several individual images into a single tiled image and display the tiled image using the imshow function.

out = imtile({'peppers.png', 'ngc6543a.jpg'});