Add object to an image
3 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Akira Agata
on 8 Nov 2019
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 Comments
Akira Agata
on 11 Nov 2019
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)
More Answers (0)
See Also
Categories
Find more on Convert Image Type in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!