open a transparent png and a jpg background together on a single graphical window
조회 수: 1 (최근 30일)
이전 댓글 표시
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/164801/image.jpeg)
2. transparent png image:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/164803/image.png)
Now, the output should look like:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/164805/image.jpeg)
(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.
댓글 수: 0
채택된 답변
Guillaume
2017년 6월 3일
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
Fakhr ElIslam Khelil
2020년 6월 13일
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!