MATLAB Answers


Insert PNG image into normal image

Asked by king umar on 18 Sep 2019 at 7:40
Latest activity Edited by Rik
on 18 Sep 2019 at 14:08
Normally, there is no problem, if we load two images in jpg formats, and insert one image to another as logo. But due to background and boarders, we need to insert png image. the output is attached
** how to handle png images.
As we know that png images have no backgroud, but once they are loaded in matlab, background turns into black. how to handle the background.
consider following image,
img1 = imread('1.jpg');
logo = imread('logo.png');
img1(1:size(logo,1), 1:size(logo,2), :) = logo;


on 18 Sep 2019 at 10:31
@rik, totally unrelated to the question at hand, how did you write your comment above? It has a smaller font than unusual, how did you achieve that? (It would help with diagnosing a current bug where some posts can't be edited).
on 18 Sep 2019 at 10:46
@king umar, is your question about compositing two images with one having associated transparency info (i.e alpha blending)?
on 18 Sep 2019 at 11:59
@Guillaume I wrote that comment on Chrome in Android (just like this one). It does seem strange.

Sign in to comment.


1 Answer

Answer by Rik
on 18 Sep 2019 at 7:43

If you want to prevent overwriting the underlying image for some pixels, you can use a logical mask to only overwrite some pixels.

  1 Comment

king umar on 18 Sep 2019 at 9:27
I have updated the question to be precise. Kindly, give your valueable feedback.

Sign in to comment.