% clown_treesBW.m loads and displays two Matlab images. It shows how to do simple % modifications such as brightening, reverse video, superimposition, % flipping, and blurring. It also makes a graph of the gray-scale intensity % as a surface and contour graph. orient tall load clown % read a datafile called clown C=ind2gray(X,map); % the variable there is called X % convert C to a grayscale image size(C) load trees T=ind2gray(X,map); T=T(1:200,1:320); % take out a subimage same size as C figure(1) subplot(4,2,1) imshow(C,64); title('Clown') subplot(4,2,2) imshow(T,64); title('Trees') subplot(4,2,3) imshow(max(max(C))-C,64); title('1 - Clown'); subplot(4,2,4) imshow(fliplr(T)+0.4,64) title('Trees + 0.4, reversed'); subplot(4,2,5) imshow(C.*C,64); title('Clown * Clown'); subplot(4,2,6) imshow((4*C+T)/5,64); title('0.8*Clown + 0.2*Trees'); subplot(4,2,7) SC=C(:,[20:320 1:19]); imshow((4*C+SC)/5,64); title('0.8*Clown + 0.2*Shifted Clown'); subplot(4,2,8) h = fspecial('gaussian',[5 5]); % a Gaussian filter BC = filter2(h,C); % apply filter to get a blurred clown BC = filter2(h,BC); % filter more BC = filter2(h,BC); BC = filter2(h,BC); BC = filter2(h,BC); BC = filter2(h,BC); fprintf('Contrast in original clown %8.4f\n',computecontrast(C)); fprintf('Contrast in blurred clown %8.4f\n',computecontrast(BC)); imshow(BC,64) title('Blurred Clown') figure(2) MC = fliplr(BC')'; subplot(2,1,1) mesh(MC) view(-10,50) xlabel('Horizontal'); ylabel('Vertical'); zlabel('Intensity'); title('Surface plot of blurred clown'); subplot(2,1,2) contour(MC,40) title('Contour plot of blurred clown')