フィルターのクリア

How to combine image with mask

21 ビュー (過去 30 日間)
sina alizadeh
sina alizadeh 2017 年 1 月 6 日
回答済み: Negesse Tadesse 2019 年 9 月 1 日
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?

採用された回答

Walter Roberson
Walter Roberson 2017 年 1 月 6 日
im3 = im;
im3(mask ~= 0) = mask(mask ~= 0);
  3 件のコメント
Image Analyst
Image Analyst 2017 年 1 月 6 日
This burns it into the image. If you just want the line in the overlay above the image without altering the image at all, use plot() or line().
sina alizadeh
sina alizadeh 2017 年 1 月 7 日
i want to burns it in image , tanks for your help

サインインしてコメントする。

その他の回答 (2 件)

Changoleon
Changoleon 2017 年 1 月 6 日
編集済み: Walter Roberson 2017 年 1 月 6 日
im=double(imread('autumn.tif'));
red = im(:,:,1);
gre = im(:,:,2);
blu = im(:,:,3);
mask=255*zeros(size(red));
mask=insertShape(mask,'line',[50 50 250 250],'linewidth',10,'color',[255 255 0]);
mask_red = mask(:,:,1).*red;
mask_gre = mask(:,:,1).*gre;
mask_blu = mask(:,:,1).*blu;
  1 件のコメント
sina alizadeh
sina alizadeh 2017 年 1 月 6 日
tank's for your reply , i don't know how to use (mask_red , mask_gre , mask_blu) !

サインインしてコメントする。


Negesse Tadesse
Negesse Tadesse 2019 年 9 月 1 日
can i get split the image from the mask again? here what i want is masking rgb to gray and compress using LZW. please

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by