diff --git a/src/suite.py b/src/suite.py index cc27040..7538dab 100644 --- a/src/suite.py +++ b/src/suite.py @@ -41,7 +41,8 @@ class MainApp: # Keep track of images in dataset self.img_current = 0 - self.img_old = -1 + self.img_name = "" + self.img_old = -1 ## minus 1 to enforce full update on start self.img_max = 0 # Plots @@ -129,6 +130,9 @@ class MainApp: print("Nothing to export!") def apply_all(self, event=None): + ''' + Export given preprocess id for every image in the dataset folder + ''' img_id = self.export_id.get() img_current = copy.deepcopy(self.img_current) @@ -167,6 +171,7 @@ class MainApp: self.meta.config(state=NORMAL) self.meta.delete(1.0, END) + self.meta.insert(END, f"{self.img_name[1]}\n") # Draw all output images for idx, data in enumerate(self.output[0]): @@ -233,7 +238,14 @@ class MainApp: # print(f"Result at thres {th1}, {th2}; \tIndex {y_ind}, {x_ind} \t= {w_res}") # print(results[y_ind]) - self.axs[column, row].title.set_text(F"Mean: {np.matrix(results).mean()}") + + func = np.diag(results) + self.axs[column, row-1].clear() + self.axs[column, row-1].title.set_text("Canny F U N C") + self.axs[column, row-1].plot(func) + self.axs[column, row-1].plot(np.diff(func)) + + self.axs[column, row].title.set_text(F"Mean: {np.matrix(results).mean()}\nStd: {np.matrix(results).std()}") self.axs[column, row].imshow(results) self.axs[column, row].xaxis.set_major_formatter(lambda x, pos: str(x*canny_step)) self.axs[column, row].yaxis.set_major_formatter(lambda x, pos: str(x*canny_step)) @@ -241,7 +253,7 @@ class MainApp: def writeStats(self, img, labels, column, row): mean, std = imgStats(img) self.axs[column, row].title.set_text( - "mean: %c:%d %c:%d %c:%d \n std: %c:%d %c:%d %c:%d" + "Mean: %c:%d %c:%d %c:%d \nStd: %c:%d %c:%d %c:%d" %(labels[0], mean[0], labels[1], mean[1], labels[2], mean[2], labels[0], std[0], labels[1], std[1], labels[2], std[2])) @@ -262,10 +274,11 @@ class MainApp: if path != None and path != "": # Get all images at current path images = [] - for file in glob.glob(path + "/*.png"): + for file in glob.glob(path + "/*.jpg"): images.append(file) self.img_max = len(images) + self.img_name = os.path.split(images[self.img_current]) # Get all user vars ct1 = self.canny_thr1.get() @@ -319,7 +332,6 @@ class MainApp: # Canny edge img_canny = cv2.Canny(image=img_blur,threshold1=ct1,threshold2=ct2) self.add_output(img_canny, "Canny_edge") - self.writeStats(img, ('B', 'G', 'R'), 0, 0) # BGR self.add_output(img[:, :, 0], "BGR_B") @@ -328,6 +340,7 @@ class MainApp: if img is not None: self.drawHist(img, ('B', 'G', 'R'), 0, 0) + self.writeStats(img, ('B', 'G', 'R'), 0, 0) # HSV img_hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)