I have a transparent .png picture when I add it to the current figure the background of it changes to black!
31 次查看(过去 30 天)
显示 更早的评论
Hey all, I wanted to add a picture of my current figure. The picture is transparent png but when I added to my figure a black background appears with it. please see the picture below (in this picture the 2 png pictures are 2 small colorful circles and the current figure is a map of country:
This happening while my circle is png and transparent:
I don't know what is this black background, I want to delete it. The code that I used is:
%read map (tif file)
[A,R] = readgeoraster('DEM_30s.tif', 'OutputType', 'double');
low_single = typecast(uint8([255 255 127 255]), 'single');
mask = low_single==A;
A = A - min(A(~mask), [], 'all');
% creating colormap changing from white to brown as shown in image in the question
brown_color = [0.8 0.2 0.1];
light_brown = [0.95 0.9 0.8];
t = linspace(0, 1, max(A,[],'all'))';
cmap = t.*brown_color + (1-t).*light_brown;
% plot tif file
gs = geoshow(A, cmap, R);
gs.CData(repmat(mask,1,1,3)) = 255;
axis equal
box on
hold on
% read small circle
img = imread('filename1.png');
image('CData',img,'XData',[50 52],'YData',[30 32])
hold off
0 个评论
采纳的回答
Ameer Hamza
2020-4-13
编辑:Ameer Hamza
2020-4-13
Read the transperancy map and use it to make the background transparent.
% read small circle
[img, ~, tr] = imread('test.png');
im = image('CData',img,'XData',[50 52],'YData',[30 32]);
im.AlphaData = tr;
hold off
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!