%
% hw01.m
%
% 02/04/02 jph
%
%   02/05/02: histograms are no longer required. jph
%

%
% Open the files containing lena.bin and peppers.bin
%
fidLena = fopen('/home/joebob/Images/lena.bin','r');
fidPeppers = fopen('/home/joebob/Images/peppers.bin','r');

%
% Read the images and transpose
%
[Lena,junk] = fread(fidLena,[256,256],'uchar');
junk
[Peppers,junk] = fread(fidPeppers,[256,256],'uchar');
junk
Lena = Lena'; Peppers = Peppers';

%
% Display each image
%
figure(1);colormap(gray(256));
image(Lena);
axis('image');
title('Original Lena Image');
print -deps M_Lena.eps;
pause;

figure(2);colormap(gray(256));
image(Peppers);
axis('image');
title('Original Peppers Image');
print -deps M_Peppers.eps;
pause;

%
% Make the image J
%
J = Lena;
J(1:256,129:256) = Peppers(1:256,129:256);
figure(3); colormap(gray(256)); image(J); axis('image');
title('New Image J');
print -deps M_J.eps;
pause;

%
% Make the image K
%
K = Lena;                     % this just sets up K to be the right size
K(1:256,1:128) = J(1:256,129:256);
K(1:256,129:256) = J(1:256,1:128);
figure(4); colormap(gray(256)); image(K); axis('image');
title('New Image K');
print -deps M_K.eps;
pause;
