open a transparent png and a jpg background together on a single graphical window

1 vue (au cours des 30 derniers jours)
Hello everyone,
I have 2 images. One is a normal jpg image (i.e. Background) and another is a .png image with the transparency. I want to open this transparent png on jpg image such that it looks like given below:
1. jpg image:
2. transparent png image:
Now, the output should look like:
(Note: You can see that the transparency is maintained in output image.)
Can anyone help me? (These images are just for giving clear explanation of my problems. Actual images are similar to them.)
Thanks in advance.

Réponse acceptée

Guillaume
Guillaume le 3 Juin 2017
bgimage = imread('e8b66924592e1115398fe4a53bd6415c.jpg');
imshow(bgimage);
hold on; %so the second image is displayed on top of the first
[fgimage, ~, alpha] = imread('Abstract-Circular-Design.png');
hfg = imshow(fgimage);
hfg.AlphaData = alpha; %set transparency
hfg.XData = [100 500]; %change position and size as appropriate
hfg.YData = [100 500];
  2 commentaires
MathReallyWorks
MathReallyWorks le 3 Juin 2017
Thank you so much Guillaume. You are awesome.
Fakhr ElIslam Khelil
Fakhr ElIslam Khelil le 13 Juin 2020
thanks you sir , you just solved a big problem for me, i used the same code with some modification to play a png over a cam preview , thank you so much

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Lighting, Transparency, and Shading dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by