How to layer image with transparency on top of plot
조회 수: 3 (최근 30일)
이전 댓글 표시
I have x y data that I wish to plot. I wish to compare the data to that of someone else, and the only format I have their data is in PNG format. I have removed the background from the PNG file to make it transparent, so the only opaque graphics are the data points in that PNG. I wish to plot my data UNDERNEATH the image file by taking advantage of the transparency.
The currently closest solution I've had is as in this example:
plot(0.5,0.5,'+','markersize',20); hold on
img = imshow('image.png','XData',[0 1],'YData',[0 1]);
[~, ~, alphachannel] = imread(file_diff);
set(img,'Alphadata',alphachannel);
xlabel('X[-]');
ylabel('Y[-]' );
ylim([0,1]);xlim([0 1])
But this removes my axes and seems to make all white transparent. The only transparency I want is for the image, and to place that on top of the figure. How can I do this?
댓글 수: 0
답변 (1개)
Image Analyst
2020년 5월 18일
편집: Image Analyst
2020년 5월 18일
You might just try taking a weighted average of the two images
factor = 0.3; % Whatever...
image3 = uint8(factor * double(image1) + (1 - factor) * double(image2));
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!