0

I'm working on a CT scan analyzer and i use this function to show some of the results:

def plot_slices(ct):
    plt.figure()
    plt.subplot(1,3,1)
    plt.imshow(ct[int(ct.shape[0]/3),:,:], cmap = 'gray')
    plt.subplot(1,3,2)
    plt.imshow(ct[int(ct.shape[0]/2),:,:], cmap = 'gray')
    plt.subplot(1,3,3)
    plt.imshow(ct[int(ct.shape[0]*2/3),:,:], cmap = 'gray')
    plt.show()

but since I'm using a Tkinter GUI app I want the results to show on the GUI frame or another window instead of the Cell output of my jupyter notebook This is how o created the GUI I know it's not the best so I accept any other suggestion to it

class App(tk.Tk):
    def __init__(self):
        tk.Tk.__init__(self)
        self.title("CT Viewer")
        self.geometry("800x600")
        self.folder = tk.StringVar()
        self.HU = tk.StringVar()
        self.folder_selected = tk.StringVar()
        self.HU_selected = tk.StringVar()
        self.folder_selected.set("No folder selected")
        self.HU_selected.set("No HU selected")
        self.folder_label = tk.Label(self, textvariable = self.folder_selected)
        self.folder_label.pack()
        self.HU_label = tk.Label(self, textvariable = self.HU_selected)
        self.HU_label.pack()
        self.folder_button = tk.Button(self, text = "Select folder", command = self.select_folder)
        self.folder_button.pack()
        self.HU_button = tk.Button(self, text = "Select HU", command = self.select_HU)
        self.HU_button.pack()
        self.plot_button = tk.Button(self, text = "Plot", command = self.plot)
        self.plot_button.pack()
        self.plot_3D_button = tk.Button(self, text = "Plot 3D", command = self.plot_3D)
        self.plot_3D_button.pack()
        self.quit_button = tk.Button(self, text = "Quit", command = self.quit)
        self.quit_button.pack()
    def select_folder(self):
        self.folder_selected.set(select_folder())
    def select_HU(self):
        self.HU_selected.set(select_HU())
    def plot(self):
        slices, ds = read_dicom(self.folder_selected.get())
        ct = adjust_contrast(slices,ds)
        ct = normalize_image(ct, int(self.HU_selected.get()))
        plot_slices(ct)
    def plot_3D(self):
        slices, ds = read_dicom(self.folder_selected.get())
        ct = adjust_contrast(slices,ds)
        ct = normalize_image(ct, int(self.HU_selected.get()))
        plot_3D(ct)

0 Answers0