def upload(event=None):
     global image_preview, image_preview01, image_preview02, image_preview03
     print('Uploads image')
     path = "/home/pi/DC-Box/leaf_upload.png"
     path_canny = "/home/pi/DC-Box/leaf_canny.png"
     path_gray = "/home/pi/DC-Box/leaf_gray.png"
     path_background = "/home/pi/DC-Box/leaf_background.png"
     
     filename = filedialog.askopenfilename(initialdir = "/home/pi/",title = "Select file",filetypes = (("jpeg files","*.jpg"),("png files","*.png"),("all files","*.*")))
     image_upload = filename
     upload(image_upload, path)
     canny(image_upload, path_canny)
     gray(image_upload, path_gray)
     background(image_upload, path_background)
     
     image_preview = ImageTk.PhotoImage(Image.open("leaf_upload.png"))
     image_panel01 = tk.Label(previewimageframe, image = image_preview)
     image_panel01.grid(column=0, row=2, sticky="W")
     
     image_preview01 = ImageTk.PhotoImage(Image.open("/home/pi/DC-Box/leaf_canny.png"))
     image_panel01 = tk.Label(section04, image = image_preview01)
     image_panel01.grid(column=0, row=1, sticky="W")
     
     image_preview02 = ImageTk.PhotoImage(Image.open("/home/pi/DC-Box/leaf_gray.png"))
     image_panel02 = tk.Label(section04, image = image_preview02)
     image_panel02.grid(column=1, row=1, sticky="W")
     
     image_preview03 = ImageTk.PhotoImage(Image.open("/home/pi/DC-Box/leaf_background.png"))
     image_panel03 = tk.Label(section04, image = image_preview03)
     image_panel03.grid(column=2, row=1, sticky="W")   
 def stop_preview_live(self):
     if not self.thread is None:
         self.thread_stop = True
         print('Stop preview Image (Live Video)')
         self.livepreview_text.set('Live-Preview')
         time.sleep(2)
         print('Preview Image (Live Video) is stopped')
         self.thread = None
         self.current_image_path = './preview.png'
         upload_image = upload(self.current_image_path)
         self.update_images(upload_image)
    def upload(self, event=None):
        self.live_preview = False
        #        global image_preview, image_preview01, image_preview02, image_preview03
        print('Uploads image')
        filename = filedialog.askopenfilename(
            initialdir="./",
            title="Select file",
            filetypes=(("jpeg files", "*.jpg"), ("png files", "*.png"),
                       ("all files", "*.*")))
        self.current_image_path = filename
        upload_image = upload(filename)

        self.update_images(upload_image)