Compare commits

...

2 Commits

View File

@ -93,6 +93,31 @@ class MainApp:
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)
@ -112,9 +137,6 @@ class MainApp:
# Get all user vars
ct1 = self.canny_thr1.get()
ct2 = self.canny_thr2.get()
print(f"canny 1: {ct1}, canny2: {ct2}")
br = self.blur_rate.get()
sxy = self.sobel_select.get()
size = self.img_size.get()
@ -182,6 +204,8 @@ class MainApp:
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