function [ newImage ] = combineLooping( image1, image2 )
%COMBINELOOPING Merge image1 and image2 into a single image.
% The left side of the merged image is the left side of image1 and the
% right side is the right side of image2. Use loops to step through the
% pixels of the images and an if statement to decide which image to pull
% each pixel of the result from.

newImage = uint8( zeros( size(image1) ) );

nRows = size( image1, 1 );
nCols = size( image1, 2 );

midCol = round( nCols / 2 );

for r = 1 : nRows
    for c = 1 : nCols
        if c <= midCol
            newImage(r,c,1) = image1(r,c,1);
            newImage(r,c,2) = image1(r,c,2);
            newImage(r,c,3) = image1(r,c,3);
        else
            newImage(r,c,1) = image2(r,c,1);
            newImage(r,c,2) = image2(r,c,2);
            newImage(r,c,3) = image2(r,c,3);
        end
    end
end

end

