2

We are using the tkinter library and Image class to display images from a file. In the program we change the pixels (so we have an array with new pixels) and want to display it in the tkinter window as well. (we can't use plt.show() or smth like this, we need to change pixels in Image, because it works only with it)

image = Image.open(files_name)
img = ImageTk.PhotoImage(image)
disp_img.config(image=img)
disp_img.image = img

The best option we've seen is .putpixel. But 1) changing each pixel separately is too long 2) it has a strange parameters, and we are not sure about using it

Eugene
  • 21
  • 3
  • 1
    You can use [`.getdata()`](https://pillow.readthedocs.io/en/stable/reference/Image.html#PIL.Image.Image.getdata) of `Image` class to get the pixel values, update the pixels and then use [`.putdata()`](https://pillow.readthedocs.io/en/stable/reference/Image.html#PIL.Image.Image.putdata) to update the image. – acw1668 Nov 14 '22 at 08:20
  • [See this Q&A](https://stackoverflow.com/a/29774796/13629335) – Thingamabobs Nov 14 '22 at 10:51

0 Answers0