简体   繁体   English

使用Matlab和其他程序在Mac上导出PNG时出现白线

[英]White lines when exporting PNG on Mac using Matlab and other programs

When I export figures in Matlab and increase resolution or magnify the image using for example export_fig test.png -m3.0 the saved image has large white lines across it. 当我在Matlab中导出数字并使用例如export_fig test.png -m3.0增加分辨率或放大图像时,保存的图像上有大的白线。

Image without magnification: 无放大图像:

在此输入图像描述

Image using -m3.0: 使用-m3.0的图像:

在此输入图像描述

The code used was 使用的代码是

%% test
figure('position', [100, 100, 350, 350]);
surf(peaks(10))
colormap(jet)
caxis([-5,10])
view(0,90)
export_fig png_test.png -transparent -m3.0;
%export_fig png_test.png -transparent -m1.0; % this works, but not high
%    enough resolution

I have also had this problem with other programs on my Mac running OS X Yosemite 10.10.5, but can't seem to reproduce it at the moment. 我在运行OS X Yosemite 10.10.5的Mac上的其他程序也遇到了这个问题,但目前似乎无法再现它。

I've tried using the reslution tag eg -r300 for export_fig, but it does the same thing. 我尝试过使用-r300标签,例如-r300用于export_fig,但它也做了同样的事情。

Also I think (probably wrong) the program actually saving the image is opengl, perhaps there is a problem with this? 另外我认为(可能是错误的)实际保存图像的程序是opengl,也许这有问题吗?

Any suggestions would be greatly appreciated. 任何建议将不胜感激。 Thank you. 谢谢。

I recommend the following: 我推荐以下内容:

set(gcf, 'InvertHardCopy', 'off');  % keep figure from changing properties
saveas(gcf, [path,filesep,fName], 'png')

If you want to be able to do it interactively with the regular "Save figure" tool in the toolbar, use the following: 如果您希望能够使用工具栏中的常规“保存图”工具以交互方式执行此操作,请使用以下命令:

hToolbar = findall(gcf,'tag','FigureToolBar');
t = findall(hToolbar);
saveFile = findobj(t,'Tag', 'Standard.SaveFigure');
set(saveFile,'ClickedCallback',@saveFigFcn)


function saveFigFcn(~,~)
    [fName, path, filterindex] = uiputfile({'*.png'},'Save as');
    if filterindex
        set(gcf, 'InvertHardCopy', 'off');
        saveas(gcf, [path,filesep,fName], 'png')
    end
end

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM