function output = canvas( image1, image2, pos )

% Merge two images together.

X = max(-pos+[1 1],[1 1]);
H = max(size(image2)+pos, size(image1)) + X;

p1 = X;
p2 = X+pos;

% Overlap
output = ones(H);
output(p1(1):p1(1)+size(image1,1)-1,p1(2):p1(2)+size(image1,2)-1) = image1(:,:);
output(p2(1):p2(1)+size(image2,1)-1,p2(2):p2(2)+size(image2,2)-1) = image2(:,:);

% 50/50 Blend
imageA = ones(H);
imageB = ones(H);
imageA(p1(1):p1(1)+size(image1,1)-1,p1(2):p1(2)+size(image1,2)-1) = image1(:,:) * 0.5;
imageB(p2(1):p2(1)+size(image2,1)-1,p2(2):p2(2)+size(image2,2)-1) = image2(:,:) * 0.5;
output = (imageA*0.5 + imageB*0.5);


end

