diff --git a/src/helpers/gui/main.ui b/src/helpers/gui/main.ui index 05cdc74..6f882ea 100644 --- a/src/helpers/gui/main.ui +++ b/src/helpers/gui/main.ui @@ -28,50 +28,49 @@ - top + bottom 0 1000 int:canny_thr1 - 0 - 60 + 1 0 - 0 + 1 - Canny Edge threshold 1 - - 0 - 1 - - - - - - 0 - 1000 - int:canny_thr2 - + Canny thresh. 1 1 - 2 - 60 0 - - Canny Edge threshold 2 + + bottom + 0 + 1000 + int:canny_thr2 + - 1 - 2 - 5 + 2 + 1 1 + + + + + + Canny thresh. 2 + + 2 + 1 + 5 + 0 1 @@ -80,73 +79,65 @@ true string:img_path + Dataset directory 0 1 30 - 4 + 7 1 - - Dataset path - - 0 - 1 - 5 - - - - - + + bottom 0 - 30 - int:blur_rate + 500 + int:contrast 0 60 0 - 2 - - - - - - Blur kernel size - - 0 3 + + + Contrast adjust + + 0 + 2 + + + - top + bottom 10 1000 int:img_size - 0 - 1 + 1 + 2 60 - 6 + 3 1 - Size + Display size adjust - 0 - 1 - 7 + 1 + 2 + 2 1 @@ -157,66 +148,58 @@ x y both - 1 - 2 - 40 - 2 - - - - - - Sobel edge - - 1 - 2 - 5 - 3 - - - - - - Prev img - - - 1 - 10 - 4 - - - - - - Next img - - - 2 - 10 - 4 - - - - - - Switch image - - 1 - 2 - 5 + 0 + 1 + 42 5 + + + center + Sobel edge + + 0 + 1 + 4 + + + + + + < Prev img + + + 1 + 10 + 5 + 1 + + + + + + Next img > + + + 2 + 10 + 5 + 1 + + + - Export dataset + Useless button 2 1 0 - 6 + 7 + 1 @@ -224,25 +207,27 @@ int:export_id 15 - - 1 - 6 - - - - - - Img to export 1 7 + + + Useless imput + + 1 + 2 + 6 + + + - 10 + 15 0 + 4 disabled Image metadata should appear here 25 @@ -255,6 +240,48 @@ + + + bottom + -500 + 500 + int:brightness + + + 0 + 60 + 1 + + + + + + Brightness adjust + + 0 + 0 + + + + + + Dataset path + + 0 + 6 + + + + + + Image control + + 1 + 2 + 4 + + + diff --git a/src/suite.py b/src/suite.py index c04a365..f357275 100644 --- a/src/suite.py +++ b/src/suite.py @@ -47,11 +47,13 @@ class MainApp: self.canny_thr1 = None self.canny_thr2 = None self.img_path = None - self.blur_rate = None + self.contrast = None self.img_size = None self.sobel_select = None self.export_id = None - builder.import_variables(self, ['canny_thr1','canny_thr2','img_path','blur_rate','img_size', 'sobel_select', 'export_id']) + self.brightness = None + builder.import_variables(self,['canny_thr1','canny_thr2','img_path','contrast','img_size','sobel_select','export_id','brightness']) + builder.connect_callbacks(self) # Load values from config after UI has been initialised @@ -189,7 +191,8 @@ 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()}") 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)) @@ -215,9 +218,10 @@ class MainApp: # Get all user vars ct1 = self.canny_thr1.get() ct2 = self.canny_thr2.get() - br = self.blur_rate.get() sxy = self.sobel_select.get() size = self.img_size.get() + contrast = self.contrast.get() + bright = self.brightness.get() # Import and resize image img = cv2.imread(images[self.img_current]) @@ -228,15 +232,15 @@ class MainApp: img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) self.add_output(img_gray, "Grayscale") + # Contrast / brightness boost + contrast_val = contrast / 100 + bright_val = bright / 100 + img_contrast = np.clip(contrast_val * (img_gray + bright_val), 0, 255).astype(np.uint8) + self.add_output(img_contrast, F"Contrast / Brightness\n c+{contrast_val} b+{bright_val}") + # Blurred edition - if (br == 0): - img_blur = img_gray - elif (br % 2 == 1): - img_blur = cv2.GaussianBlur(img_gray, (br, br), 0) - else: - print(f"Blur rate changed to {br - 1}") - img_blur = cv2.GaussianBlur(img_gray, (br-1, br-1), 0) - self.add_output(img_blur, "Blurred") + img_blur = cv2.GaussianBlur(img_gray, (3, 3), 0) + self.add_output(img_blur, "Blurred (3)") # Sobel edge if sxy in ['x', 'y', 'both']: @@ -253,7 +257,7 @@ class MainApp: img_sobel = cv2.Sobel(src=img_blur, ddepth=cv2.CV_8U, dx=dx, dy=dy, ksize=5) else: img_sobel = img_gray - self.add_output(img_sobel, "Sobel Edge") + self.add_output(img_sobel, F"Sobel Edge\n nz={cv2.countNonZero(img_sobel)}") # Canny edge img_canny = cv2.Canny(image=img_blur,threshold1=ct1,threshold2=ct2)