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.
imshow(RGB)
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.
imshow(gray)
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'}); imshow(out);