How can i put an image inside this frame ?
1 view (last 30 days)
Show older comments
i have to write a function that puts an image inside this frame
the image should be in the white part
can someone help me because i have no idea how to do it
0 Comments
Answers (1)
Ameer Hamza
on 29 Sep 2020
Edited: Ameer Hamza
on 29 Sep 2020
Something like this
img_foreground = imread('peacock.jpg');
img_background = imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/368509/image.jpeg');
img_gray = rgb2gray(im2double(img_background));
mask = img_gray > 0.9;
[r1, c1] = find(mask, 1);
[r2, c2] = find(mask, 1, 'last');
w = c2 - c1 + 1;
h = r2 - r1 + 1;
img_foreground = imresize(img_foreground, [h w]);
img = img_background;
img(r1:r2, c1:c2, :) = img_foreground;
The actual image has low resolution, so the resolution of the foreground image also needs to be reduced to fit the size.
0 Comments
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!