Contents

Download image

I = imread('https://upload.wikimedia.org/wikipedia/en/7/7d/Lenna_%28test_image%29.png');

%display image
figure(1); image(I); axis image
title('Input Image')

Crop the image by 50 pixels on each side

c = 50

%--fill your code here
%Ic =

%display image
figure(2); image(Ic); axis image
title('Cropped image')
size(Ic)
c =

    50


ans =

   412   412     3

Convert image to grayscale

% GrayScale = 0.2989 * R + 0.5870 * G + 0.1140 * B

%--fill your code here
%J =

J = uint8(J);


% Create 3-channel grayscale images (same value for all channels)

%--fill your code here
%K =

K = uint8(K);

figure(3); image(K); axis image;
title('Grayscale image')
K =

     []

Highlight high/low intensity pixels

%- show high intensity pixels in red (I>200);
%- show low intensity in blue (I<50);

L = K;

%--fill your code here
%L =

figure(4); image(L); axis image
title('Intensity highlighted image')

Add a yellow 10px-thick border around the resulting image

%--fill your code here
%M =


figure(5); image(M); axis image
size(M);
title('Image with a yellow border');

%store the image as JPEG
imwrite(M,'result.jpg')

%read from disk
N = imread('result.jpg');
figure(6); image(N); axis image
title('Resulting image read from disk')