我已經在我的作業系統(Debian 11 lxde)中設定了默認的應用程式--gimp來打開影像。
下面的python代碼將在你的默認影像瀏覽器中打開影像,在so:
打開一個新的視窗來顯示影像
>>> from PIL import Image
>>> img = Image.open('test.png'/span>)
>>> img.show()
為什么在我的作業系統中執行時沒有打開新的視窗,而且gimp開始顯示圖片?
uj5u.com熱心網友回復:
要在Debian安裝matplotlib,請運行sudo apt install python3-matplotlib。使用matplotlib Python模塊中的pyplot來顯示圖片,如下所示。
importmatplotlib.pyplot as plt
from PIL import Image
plt.imshow(Image.open('test.png')
plt.show()
另外,用sudo apt install eog安裝eog,你的原始代碼將在一個新視窗中顯示圖片。請注意,如果影像很小,那么新視窗也會很小,你可能不會注意到它已經打開。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/309071.html
標籤:
上一篇:如何將nii影像轉換為2D影像?

