Add object to an image
3 ビュー (過去 30 日間)
古いコメントを表示
Hi all , now i have an object and want to add it to an image using for loop .
For example : i have 'man' as 'img1' a object and want to add him to different image that have background 'img2' and result must be the same as 'img3'.
Please , help me if you can and thank you very much.
2 件のコメント
採用された回答
Akira Agata
2019 年 11 月 8 日
Like this?
% Read background and man image
Ibg = imread('img2.jpg');
Iman = imread('img.jpg');
% Adjust man's image size to the background image
Iman = imresize(Iman,size(Ibg,[1 2]));
% Create mask
BWmask = Iman(:,:,1) > 12;
BWmask = cat(3,BWmask,BWmask,BWmask);
% Add masked man to the background
Ibg(BWmask) = Iman(BWmask);
% Show the result
figure
imshow(Ibg)
7 件のコメント
Akira Agata
2019 年 11 月 11 日
How about the following?
Regarding the "Color Thresholder App", the following help page will be useful.
I = imread('jump.jpg');
% Threshold was adjusted by usign "Color Thresholder App"
Ilab = rgb2lab(I);
BW = Ilab(:,:,3) > -20;
% Extract only target ROI
BW = imclearborder(BW);
BW = bwareafilt(BW,1);
% Making a binary mask image which has RGB dimension
BWmask = cat(3,BW,BW,BW);
% Multiply to the original image and obtain the result
I2 = immultiply(I,BWmask);
% Show the result
figure
imshow(I2)
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Convert Image Type についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!