mask rcnn 中matplotlib 使用 plt.savefig() 输出图片去除旁边的空白区域(保存原图)

最近导师要求mask rcnn中显示结果没有白色的边,图像不被压缩,生成mask,经过千辛万苦,终于解决,特记录。

1.去掉坐标轴,这只是坐标轴不显示,但是依然存在。

ax.axis(off)#关闭坐标轴

2.显示图片,保存图片。

fig.set_size_inches(width/100.0,height/100.0)#输出width*height像素
plt.gca().xaxis.set_major_locator(plt.NullLocator())
plt.gca().yaxis.set_major_locator(plt.NullLocator())
plt.subplots_adjust(top=1,bottom=0,left=0,right=1,hspace =0, wspace =0)
plt.margins(0,0)
plt.savefig(path)#path为你将保存图片的路径。

猜你喜欢

转载自blog.csdn.net/weixin_42618420/article/details/86218630