MATLAB: How to combine image with mask

imageimage processing

hi , i read a image and want combine with mask that contain a line on it , i make a mask but i can't combine a image and mask that show line on the reading image
im=imread('apple.jpg');
mask=255*zeros(size(im));
mask=insertShape(mask,'line',[50 50 250 250],'linewidth',10,'color',[255 255 0]);
mask=uint8(mask);
subplot(1,3,1);
imshow(im);
title('original');
subplot(1,3,2);
imshow(mask);
% how to combine im and mask
% im3 = combine(im , mask)
subplot(1,3,3)
imshow(im3);
title('combine')
how can i do this and show line mask on original image?

Best Answer

im3 = im;
im3(mask ~= 0) = mask(mask ~= 0);