A Imread Imshow A: 'Cameraman - Tif'

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

Read and display an image (grayscale):

a = imread ('cameraman.tif');
imshow (a);

Read and display an image (color):

b = imread ('peppers.png');
imshow (b);

Create a 3 x 3 matrix and display it as an image:

a=[0,0,0;0,0,0;0,0,0];
imshow (a);

Create a 3 x 3 x 3 matrix for a red square and display it as an image:

g (:, :, 1) = [255, 255, 255; 255, 255, 255; 255, 255, 255];
g (:, :, 2) = [0, 0, 0; 0, 0, 0; 0, 0, 0];
g (:, :, 3) = [0, 0, 0; 0, 0, 0; 0, 0 ,0];

g = uint8 (g);
imshow (g);

Exercises:

What color is obtained from the following 3 x 3 x 3 matrices?

g (:, :, 1) = [0, 0, 0; 0, 0, 0; 0, 0, 0];


g (:, :, 2) = [0, 0, 0; 0, 0, 0; 0, 0, 0];
g (:, :, 3) = [0, 0, 0; 0, 0, 0; 0, 0 ,0];

imshow (g);

g (:, :, 1) = [255, 255, 255; 255, 255, 255; 255, 255, 255];
g (:, :, 2) = [255, 255, 255; 255, 255, 255; 255, 255, 255];
g (:, :, 3) = [255, 255, 255; 255, 255, 255; 255, 255, 255];

g = uint8 (g);
imshow (g);

g (:, :, 1) = [127, 127, 127; 127, 127, 127; 127, 127, 127];
g (:, :, 2) = [127, 127, 127; 127, 127, 127; 127, 127, 127];
g (:, :, 3) = [127, 127, 127; 127, 127, 127; 127, 127, 127];

g = uint8 (g);
imshow (g);

Create a 3 x 3 x 3 matrix for a yellow square and display it as an image.

Create a 3 x 3 x 3 matrix for an orange square and display it as an image.

You might also like