【问题标题】:saveas white border matlabsaveas白色边框matlab
【发布时间】:2014-02-20 11:32:12
【问题描述】:
我想使用 saveas 命令将帧保存为 png 格式的图像。虽然我的图像尺寸是 640X480 (gcf),但保存的图像尺寸是 1201x901 并且空间为白色。(如粗体白色边框)。所以我希望图像保存为 640x480。
我尝试了透明背景,但它没有用。我该如何解决这个问题?
F(j) = getframe(gcf);
fname='C:\...'
saveas(gcf, fullfile(fname, 'newImage'), 'png');
【问题讨论】:
标签:
matlab
image-processing
removing-whitespace
save-as
【解决方案1】:
试试这个,
set(gca,'position',[0 0 1 1],'units','normalized')
或者你可以试试imcropfunction。
【解决方案2】:
如果您没有在图像上覆盖任何图形,则直接使用imwrite 保存图像数据,而不是将包含图像的图形导出为 png。
如果您要叠加图形,则export_fig 函数(可在 MATLAB File Exchange 上下载)将自动裁剪图形周围的空白。在这种情况下使用:
export_fig(fullfile(fname, 'newImage'), '-png', '-a1', '-native');