% clown_trees.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 % the variable there is called X C = X; % C is a single matrix Cmap = map; % the colormap tells the colors to use! CRGB = ind2rgb(C,Cmap); % CRGB is an M by N by 3 matrix load trees T = X; Tmap = map; T=T(1:200,1:320); % take out a subimage same size as C figure(1) subplot(4,2,1); imshow(C,Cmap); title('Clown') subplot(4,2,2) subimage(T,Tmap); title('Trees') subplot(4,2,3) subimage(C,1-Cmap); title('Reverse video'); subplot(4,2,4) subimage(fliplr(T),Tmap) title('Trees reversed'); subplot(4,2,5) subimage(C,Cmap.*Cmap); title('Clown * Clown (reduces intensities)'); subplot(4,2,6) %subimage((4*C+T)/5,64); %title('0.8*Clown + 0.2*Trees'); subplot(4,2,7) SC=C(:,[20:320 1:19]); subimage((4*C+SC)/5,Cmap); title('0.8*Clown + 0.2*Shifted Clown'); subplot(4,2,8) h = fspecial('gaussian',[5 5]); % a Gaussian filter CRGB = ind2rgb(C,Cmap); % convert to RGB image BC(:,:,1) = filter2(h,CRGB(:,:,1)); % apply filter to get a blurred clown BC(:,:,2) = filter2(h,CRGB(:,:,2)); % apply filter to get a blurred clown BC(:,:,3) = filter2(h,CRGB(:,:,3)); % apply filter to get a blurred clown BC(:,:,1) = filter2(h,BC(:,:,1)); % apply filter to get a blurred clown BC(:,:,2) = filter2(h,BC(:,:,2)); % apply filter to get a blurred clown BC(:,:,3) = filter2(h,BC(:,:,3)); % apply filter to get a blurred clown BC(:,:,1) = filter2(h,BC(:,:,1)); % apply filter to get a blurred clown BC(:,:,2) = filter2(h,BC(:,:,2)); % apply filter to get a blurred clown BC(:,:,3) = filter2(h,BC(:,:,3)); % apply filter to get a blurred clown BC(:,:,1) = filter2(h,BC(:,:,1)); % apply filter to get a blurred clown BC(:,:,2) = filter2(h,BC(:,:,2)); % apply filter to get a blurred clown BC(:,:,3) = filter2(h,BC(:,:,3)); % apply filter to get a blurred clown BC(:,:,1) = filter2(h,BC(:,:,1)); % apply filter to get a blurred clown BC(:,:,2) = filter2(h,BC(:,:,2)); % apply filter to get a blurred clown BC(:,:,3) = filter2(h,BC(:,:,3)); % apply filter to get a blurred clown BC(:,:,1) = filter2(h,BC(:,:,1)); % apply filter to get a blurred clown BC(:,:,2) = filter2(h,BC(:,:,2)); % apply filter to get a blurred clown BC(:,:,3) = filter2(h,BC(:,:,3)); % apply filter to get a blurred clown BC(:,:,1) = filter2(h,BC(:,:,1)); % apply filter to get a blurred clown BC(:,:,2) = filter2(h,BC(:,:,2)); % apply filter to get a blurred clown BC(:,:,3) = filter2(h,BC(:,:,3)); % apply filter to get a blurred clown subimage(BC) title('Blurred Clown')