Python plt座標軸を除去し、枠線が見えない
702 ワード
img = img.resize((input_image.shape[0], input_image.shape[1]), Image.LANCZOS)
img = np.array(img)
plt.imshow(img)
plt.axis('off')
fig = plt.gcf()
fig.set_size_inches(1.0 / 3, 1.0 / 3) # dpi = 300, output = 100*100 pixels
plt.gca().xaxis.set_major_locator(plt.NullLocator())
plt.gca().yaxis.set_major_locator(plt.NullLocator())
plt.subplots_adjust(top=1, bottom=0, right=1, left=0, hspace=0, wspace=0)
plt.margins(0, 0)
frame = plt.gca()
# y
frame.axes.get_yaxis().set_visible(False)
# x
frame.axes.get_xaxis().set_visible(False)
fig.savefig(layer_name.split('/')[0] +'_'+str(i)+ '.png', transparent=True, dpi=300, pad_inches=0)