0
PIL로 이미지를로드 한 다음 추가 조작을 위해 배열로 변환 한 다음 다시 이미지로 변환하고 Tkinter Label 요소에 표시하고 싶습니다. 내가 실수를 가지고 실행하면PIL을 사용하여 Tkinter에서 numpy 배열로 표시 이미지 표시
from tkinter import *
import PIL as pl
from PIL import ImageTk, Image
import numpy as np
root = Tk()
root_panel = Frame(root)
root_panel.pack(side="bottom", fill="both", expand="yes")
img_src = 'pic.jpg'
img = pl.Image.open(img_src)
img_arr = np.array(img)
img = pl.Image.fromarray(img_arr)
img_panel = Label(root_panel)
img_panel.configure(image=img)
img_panel.pack(side="bottom", fill="both", expand="yes")
root.mainloop()
: 나는 다음과 같은 코드를 가지고 것 같다
File "C:/Users/lazar/Documents/GitHub/Face-Features-Detection/ui.py", line 19, in <module>
img_panel.configure(image=img)
File "C:\Users\a\Miniconda3\lib\tkinter\__init__.py", line 1479, in configure
return self._configure('configure', cnf, kw)
File "C:\Users\a\Miniconda3\lib\tkinter\__init__.py", line 1470, in _configure
self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
_tkinter.TclError: image "<PIL.Image.Image image mode=RGB size=295x400 at 0x28CAB9F5630>" doesn't exist
이 (<PIL.Image.Image image mode=RGB size=295x400 at 0x28CAB9F5630>
를) 찾을 수 있지만, 어떤 이유로 인쇄를 위해 존재하지 않는다. 아무도이 문제를 일으킬 수 제안하시기 바랍니다 수 있습니까? 그것은 (단지`ImageTk.PhotoImage를 표시 할 수 있습니다)`-
img_tk = ImageTk.PhotoImage(img)
img_panel = Label(root_panel)
img_panel.configure(image=img_tk)
'tkinter''Image'를 표시 할 수 없습니다 : – furas