今天做一组图像处理,存储图像发现图片周边一圈白边,搜罗花了点小时间,现记录一下如何无白边保留figure 图像。具体如下:
(1)可以保存输入同分辨率的无白边图像代码

figure; 
h1=imshow(inputImg,'border','tight');
imwrite(h1.CData,'test.jpg')  ;

(2) 不可以的代码1 (上下仍然有白边)

h=figure; 
imshow(inputImg,'border','tight','initialmagnification','fit');
saveas(h, 'test.jpg');

(3)不可以的代码2 (没有白边,但是保存图像的分辨率已改变)

h=figure; 
imshow(inputImg,'border','tight','initialmagnification','fit');
set (gcf,'Position',[0,0,1920,1080]);  %该语句设置,其实没有起到作用
axis normal;
saveas(gca, 'test.jpg');

更多推荐