【发布时间】:2023-03-18 20:40:02
【问题描述】:
我正在尝试读取一系列 .bmp 图像,并根据我得到的提示进行一些线性对比度调整。这些图像很小,112x112,我希望它们看起来完全一样,除了对比度调整。我试过用 matplotlib 来做,但无论我做什么,我都会在图像边界周围得到空白。这是我正在使用的代码:
# 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')
关于如何删除填充的任何提示?我已经做了一些谷歌搜索,但到目前为止我发现没有任何工作。
【问题讨论】:
标签: python matplotlib