Transparent background+setting alpha data
2 ビュー (過去 30 日間)
古いコメントを表示
Hi: I have matrix
x=[1 2 3; 0 2 3;0 0 3];
I want to create a png file where the 0s are transparent and the rest of values are half transparent...I tried the following:
x(x<=0)=NaN;
h=imagesc(x);
axis image
set(h,'alphadata',~isnan(x))
set(gca,'color','none');
set(gca, 'visible', 'off') ;
export_fig asda.png -transparent
(search expor_fig on this site you will find it,saveas acts weird sometimes so I prefer this one).
Problem is how do I make the rest of the ~isnan values half transparent?
if I use alpha(.5) the NaN will get back their colors (cancels the 'alphadata' command)
Thanks,
0 件のコメント
採用された回答
その他の回答 (1 件)
Image Analyst
2012 年 9 月 30 日
Have you seen the official Mathworks documentation: http://www.mathworks.com/help/matlab/ref/imwrite.html#f25-742371
参考
カテゴリ
Help Center および File Exchange で Image Processing Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!