function uim = upsample(image, duplicate)
% upsample the image, duplicating the pixels if asked

s = size(image);
uim = zeros(2*s);
uim(1:2:2*s(1),1:2:2*s(2)) = image; 

if(nargin == 2)
   uim(2:2:2*s(1),1:2:2*s(2)) = image; 
   uim(1:2:2*s(1),2:2:2*s(2)) = image; 
   uim(2:2:2*s(1),2:2:2*s(2)) = image; 
end
