fig, ax1 = plt.subplots(1, 1) ax1.imshow(pic, cmap=plt.cm.gray) ax1.axis('off') height, width = pic.shape # 如果dpi=300,那么图像大小=height*width fig.set_size_inches(width / 100.0, height / 100.0) 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.savefig('pic.png') plt.show()
plt.画图去除白色边框
最新推荐文章于 2023-04-12 16:59:09 发布