%Indexing and assigning arrays

%Load in the images
einstein_im = imread('data/einstein.png');
trump_im = imread('data/trump.png');

%View them as images in a Matlab figure window
figure;
imshow(einstein_im);
figure; %If you don't do this, your previous image gets overwritten 
imshow(trump_im);
%%
%Now index into the 2 images arrays to create new variables
einstein_eyes_rows = 80:105;
einstein_eyes_cols = 96:160;
trump_eyes_rows = 53:78;
trump_eyes_cols = 100:164;

einstein_eyes = einstein_im(einstein_eyes_rows, einstein_eyes_cols);
trump_eyes = trump_im(trump_eyes_rows, trump_eyes_cols);

%Look at these two - as a neat trick, I've used sub-plot to show them in
%the same figure window
figure;
subplot(2,1,1); imshow(einstein_eyes);
subplot(2,1,2); imshow(trump_eyes);
%%
%Now take copies of the two original images, and then assign
%the eyes into the copies
einstein_im_copy = einstein_im;
trump_im_copy = trump_im;

einstein_im_copy(einstein_eyes_rows, einstein_eyes_cols) = ...
    trump_eyes;
trump_im_copy(trump_eyes_rows, trump_eyes_cols) = ...
    einstein_eyes;

figure;
imshow(einstein_im_copy);
figure;
imshow(trump_im_copy);