0

I get a numpy array from my hamamatsu camera and i want to show it on a canvas widget from tkinter and save it as TIFF or PNG, i use this part of code for it:

val_fin.dtype==np.uint16
val_max = np.amax(val_fin)
val_mul = int(65535/val_max)
val_fin = val_fin*val_mul

imcv2 = Image.fromarray(val_fin)
imcv2 = imcv2.convert('I;16')
altura, anchura = imcv2.size
print(altura,anchura)
path = filedialog.asksaveasfilename(title="Guardar imagen",
                                    filetypes=[("TIFF", '.TIFF'), ("PNG", '*.png')],
                                    defaultextension='.TIFF')

imcv2.save(path)
photo = ImageTk.PhotoImage(imcv2)


marco = tk.Canvas(root,width=anchura, height=altura)
marco.pack()
marco.create_image(10,10, image=photo, anchor='nw')
root.mainloop()

val_fin is the start array, it saves the image correctly but shows a withe image on the canvas, any idea? Thanks

  • 1
    is this code inside a function? https://stackoverflow.com/questions/16424091 – Bryan Oakley Oct 13 '21 at 11:08
  • No, this is the "main" code, the canvas widget appears but shows a withe image, i think it´s a format problem (format between the numpy array and the creates tkinter image) – Diego Gonzalez Oct 13 '21 at 20:32

0 Answers0