0001 function output = draw_overlay(bg, overlay) 0002 mask = rgb2gray(overlay); 0003 overlayR = overlay(:,:,1); 0004 overlayG = overlay(:,:,2); 0005 overlayB = overlay(:,:,3); 0006 overlayR(mask==0)= bg(mask==0); 0007 overlayG(mask==0)= bg(mask==0); 0008 overlayB(mask==0)= bg(mask==0); 0009 0010 output = [overlayR overlayG overlayB]; 0011 output = reshape(output,[size(overlayR,1), size(overlayR,2), 3]);