% Problem 1 % ========= % See documentation in each of the functions for how the problem is solved. % Here lets show that they work. Consider a 5 x 3 image (M=5, N = 3). By hand you % should be able to show that the following m, n, and l tripples hold % m n l % ----- % 1 1 1 % 2 1 2 % 3 2 8 % 1 3 11 clc l1 = rc2lex(1,1,5,3); l2 = rc2lex(2,1,5,3); l3 = rc2lex(3,2,5,3); l4 = rc2lex(1,3,5,3); [m1 n1] = lex2rc(1,5,3); [m2 n2] = lex2rc(2,5,3); [m3 n3] = lex2rc(8,5,3); [m4 n4] = lex2rc(11,5,3); % Show the results disp([l1 l2 l3 l4]) disp([m1 n1]) disp([m2 n2]) disp([m3 n3]) disp([m4 n4]) % McAndrew Problem 2.2 % ==================== % We'll work on the cameraman image % Load the image into Matlab a = imread('cameraman.tif'); % Write the image in the three different formats imwrite(a,'cman.jpg'); imwrite(a,'cman.png'); imwrite(a,'cman.bmp'); % Using imfinfo to get the information about the differnt files. Note how % we access only FileSize field tmp1 = imfinfo('cameraman.tif'); tif_size = tmp1.FileSize tmp2 = imfinfo('cman.jpg'); jpg_size = tmp2.FileSize tmp3 = imfinfo('cman.png'); png_size = tmp3.FileSize tmp4 = imfinfo('cman.bmp'); bmp_size = tmp4.FileSize % McAndrew Problem 2.3 % ==================== % For true color we'll use autumn.tif cameraman image a = imread('autumn.tif'); imwrite(a,'autumn.jpg'); imwrite(a,'autumn.png'); imwrite(a,'autumn.bmp'); tmp1 = imfinfo('autumn.tif'); tif_size = tmp1.FileSize tmp2 = imfinfo('autumn.jpg'); jpg_size = tmp2.FileSize tmp3 = imfinfo('autumn.png'); png_size = tmp3.FileSize tmp4 = imfinfo('autumn.bmp'); bmp_size = tmp4.FileSize % For binary we'll use circbw.tif cameraman image a = imread('circbw.tif'); imwrite(a,'circbw.jpg'); imwrite(a,'circbw.png'); imwrite(a,'circbw.bmp'); tmp1 = imfinfo('circbw.tif'); tif_size = tmp1.FileSize tmp2 = imfinfo('circbw.jpg'); jpg_size = tmp2.FileSize tmp3 = imfinfo('circbw.png'); png_size = tmp3.FileSize tmp4 = imfinfo('circbw.bmp'); bmp_size = tmp4.FileSize % For indexed color we'll use shadow.tif cameraman image a = imread('shadow.tif'); imwrite(a,'shadow.jpg'); imwrite(a,'shadow.png'); imwrite(a,'shadow.bmp'); tmp1 = imfinfo('shadow.tif'); tif_size = tmp1.FileSize tmp2 = imfinfo('shadow.jpg'); jpg_size = tmp2.FileSize tmp3 = imfinfo('shadow.png'); png_size = tmp3.FileSize tmp4 = imfinfo('shadow.bmp'); bmp_size = tmp4.FileSize % Problem 3 % ========= % My appproach to solving this is to display the image using imagesc which % shows row an olumn numbvers. Zooming into the head then lets me read the % required rows and column numbers off of the plot\ cman = imread(['../text/images/cameraman.tif']); imagesc(cman) r_start = 39; r_end = 82; c_start = 97; c_end = 136; face = cman(r_start:r_end, c_start:c_end); imshow(face)