我已经构建了一个在给定画布上绘制给定图像的函数。 由于某种原因,它只绘制了最后一张图像。 我在两个画布上都有标签。 试图将self.imgGrayscale改为imgGrayscale,但它根本没有绘制
self.DrawOnCanvas(self.img,self.canvas1)
self.DrawOnCanvas(HistoImage,self.canvas2)
def DrawOnCanvas(self,getImg,canvas):
imgGrayscale = Image.fromarray(array(getImg)).resize((self.w1+2,self.h1+2))
self.imgGrayscale = ImageTk.PhotoImage(imgGrayscale)
canvas.create_image(0,0, image=self.imgGrayscale, anchor="nw")
widget = Tkinter.Label(self, text='Original Image', fg='white', bg='black')
canvas.create_window(self.w1/2, self.h1/10, window=widget)
我做错了什么?
解决方案:
self.draws=[]
self.DrawOnCanvas(imgUni,self.canvas5,HistoLUT,self.canvas6,'Lambda Transformation')
def DrawOnCanvas(self,getImg,canvas):
imgGrayscale = Image.fromarray(array(getImg)).resize((self.w1+2,self.h1+2))
self.draws.append(ImageTk.PhotoImage(imgGrayscale))
canvas.create_image(0,0, image=self.draws[-1], anchor="nw")