我正在尝试读取一系列.bmp图像,并根据我得到的提示做一些线性对比度调整。这些图像很小,112x112,我希望它们看起来完全一样,除了对比度调整。我试着用matplotlib来做这件事,但不管我做什么,我都会在图片的边框周围获得空白区域。这里是我使用的代码:从matplotlib中删除空格savefig
# Open image and convert to array
oldImage = Image.open(f)
imageArray = np.array(oldImage)
# Preprocessing
vrange = stats.mquantiles(imageArray.flatten(),prob=[0.01,0.99])
# Plot and save
fig = plt.figure()
fig.set_size_inches(1,1)
fig.set_dpi(112)
plt.imshow(imageArray,cmap="gray",interpolation="Nearest",vmin=vrange[0],vmax=vrange[1]);
plt.axis('off')
plt.savefig(f[:-4] + "_adjusted.png", bbox_inches='tight')
有关如何删除填充的任何提示?我做了一些谷歌搜索,但没有发现迄今为止工作。
相关:http://stackoverflow.com/questions/14503725/matplotlib-pyplot-imsave-backend/14506028#14506028 – tacaswell 2013-03-02 23:39:09