我有一個python腳本,它將圖像作爲輸入併爲圖像添加一些效果。添加效果後,我保存圖像,這給了我100%正確的結果。但如果做img.show()爲我以前保存相同的圖像它顯示我輸入圖像,而不是效果添加圖像。代碼在下面給出Image.save()和Image.show()給出不同的結果對於相同的圖像
import numpy as np
from PIL import Image
img = Image.open("1.png").convert('RGBA')
arr = np.array(img)
alpha = arr[:, :, 3]
n = len(alpha)
alpha[:] = np.interp(np.arange(n), [0, 0.55*n, 0.75*n, n], [255, 255, 0, 0])[:,np.newaxis]
img = Image.fromarray(arr, mode='RGBA')
img.save("2.png")
img.show()
Thnaks很多。你是對的。 –