diff --git a/src/suite.py b/src/suite.py index 08a5721..a384aa3 100644 --- a/src/suite.py +++ b/src/suite.py @@ -92,7 +92,32 @@ class MainApp: self.axs[column, row].plot(hist, label=lab) self.axs[column, row].grid() self.axs[column, row].legend() + + def drawCannyHM(self, img, column, row): + self.axs[column, row].clear() + canny_max = 500 + canny_step = 20 + results = [[] for x in range((int)(canny_max / canny_step))] + + for th1 in range(0, canny_max, canny_step): + for th2 in range(0, canny_max, canny_step): + # Canny Edge Detection + edges = cv2.Canny(image=img, threshold1=th1, threshold2=th2) + + w_res = cv2.countNonZero(edges) + y_ind = (int)(th1 / canny_step) + x_ind = (int)(th2 / canny_step) + + results[y_ind].append(w_res) + + # print(f"Result at thres {th1}, {th2}; \tIndex {y_ind}, {x_ind} \t= {w_res}") + # print(results[y_ind]) + + 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)) + def update(self, event=None): path = self.img_path.get() print(path) @@ -111,10 +136,7 @@ class MainApp: # Get all user vars ct1 = self.canny_thr1.get() - ct2 = self.canny_thr2.get() - - print(f"canny 1: {ct1}, canny2: {ct2}") - + ct2 = self.canny_thr2.get() br = self.blur_rate.get() sxy = self.sobel_select.get() size = self.img_size.get() @@ -181,7 +203,9 @@ class MainApp: output.append(img_hsv[:, :, 2]) # V if img_hsv is not None: self.drawHist(img_hsv, ('H', 'S', 'V'), 0, 1) - + + self.drawCannyHM(img, 1, 1) + plt.show(block=False) # Draw all output images