Canny F U N C
This commit is contained in:
parent
a8c7581fac
commit
0738cb6a52
23
src/suite.py
23
src/suite.py
@ -41,7 +41,8 @@ class MainApp:
|
|||||||
|
|
||||||
# Keep track of images in dataset
|
# Keep track of images in dataset
|
||||||
self.img_current = 0
|
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
|
self.img_max = 0
|
||||||
|
|
||||||
# Plots
|
# Plots
|
||||||
@ -129,6 +130,9 @@ class MainApp:
|
|||||||
print("Nothing to export!")
|
print("Nothing to export!")
|
||||||
|
|
||||||
def apply_all(self, event=None):
|
def apply_all(self, event=None):
|
||||||
|
'''
|
||||||
|
Export given preprocess id for every image in the dataset folder
|
||||||
|
'''
|
||||||
img_id = self.export_id.get()
|
img_id = self.export_id.get()
|
||||||
img_current = copy.deepcopy(self.img_current)
|
img_current = copy.deepcopy(self.img_current)
|
||||||
|
|
||||||
@ -167,6 +171,7 @@ class MainApp:
|
|||||||
|
|
||||||
self.meta.config(state=NORMAL)
|
self.meta.config(state=NORMAL)
|
||||||
self.meta.delete(1.0, END)
|
self.meta.delete(1.0, END)
|
||||||
|
self.meta.insert(END, f"{self.img_name[1]}\n")
|
||||||
|
|
||||||
# Draw all output images
|
# Draw all output images
|
||||||
for idx, data in enumerate(self.output[0]):
|
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(f"Result at thres {th1}, {th2}; \tIndex {y_ind}, {x_ind} \t= {w_res}")
|
||||||
# print(results[y_ind])
|
# 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].imshow(results)
|
||||||
self.axs[column, row].xaxis.set_major_formatter(lambda x, pos: str(x*canny_step))
|
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))
|
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):
|
def writeStats(self, img, labels, column, row):
|
||||||
mean, std = imgStats(img)
|
mean, std = imgStats(img)
|
||||||
self.axs[column, row].title.set_text(
|
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], mean[0], labels[1], mean[1], labels[2], mean[2],
|
||||||
labels[0], std[0], labels[1], std[1], labels[2], std[2]))
|
labels[0], std[0], labels[1], std[1], labels[2], std[2]))
|
||||||
|
|
||||||
@ -262,10 +274,11 @@ class MainApp:
|
|||||||
if path != None and path != "":
|
if path != None and path != "":
|
||||||
# Get all images at current path
|
# Get all images at current path
|
||||||
images = []
|
images = []
|
||||||
for file in glob.glob(path + "/*.png"):
|
for file in glob.glob(path + "/*.jpg"):
|
||||||
images.append(file)
|
images.append(file)
|
||||||
|
|
||||||
self.img_max = len(images)
|
self.img_max = len(images)
|
||||||
|
self.img_name = os.path.split(images[self.img_current])
|
||||||
|
|
||||||
# Get all user vars
|
# Get all user vars
|
||||||
ct1 = self.canny_thr1.get()
|
ct1 = self.canny_thr1.get()
|
||||||
@ -319,7 +332,6 @@ class MainApp:
|
|||||||
# Canny edge
|
# Canny edge
|
||||||
img_canny = cv2.Canny(image=img_blur,threshold1=ct1,threshold2=ct2)
|
img_canny = cv2.Canny(image=img_blur,threshold1=ct1,threshold2=ct2)
|
||||||
self.add_output(img_canny, "Canny_edge")
|
self.add_output(img_canny, "Canny_edge")
|
||||||
self.writeStats(img, ('B', 'G', 'R'), 0, 0)
|
|
||||||
|
|
||||||
# BGR
|
# BGR
|
||||||
self.add_output(img[:, :, 0], "BGR_B")
|
self.add_output(img[:, :, 0], "BGR_B")
|
||||||
@ -328,6 +340,7 @@ class MainApp:
|
|||||||
|
|
||||||
if img is not None:
|
if img is not None:
|
||||||
self.drawHist(img, ('B', 'G', 'R'), 0, 0)
|
self.drawHist(img, ('B', 'G', 'R'), 0, 0)
|
||||||
|
self.writeStats(img, ('B', 'G', 'R'), 0, 0)
|
||||||
|
|
||||||
# HSV
|
# HSV
|
||||||
img_hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
|
img_hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
|
||||||
|
Loading…
Reference in New Issue
Block a user