diff --git a/__pycache__/lumen_profiler.cpython-313.pyc b/__pycache__/lumen_profiler.cpython-313.pyc index b550c01..93eaeeb 100644 --- a/__pycache__/lumen_profiler.cpython-313.pyc +++ b/__pycache__/lumen_profiler.cpython-313.pyc Binary files differ diff --git a/gui_app.py b/gui_app.py index 140eb8b..e0073d6 100644 --- a/gui_app.py +++ b/gui_app.py @@ -44,6 +44,11 @@ self.interval_text = tk.Entry(self.analize_frame, width=5, justify=tk.RIGHT) self.interval_text.insert(tk.END, "2") self.interval_text.pack(side=tk.LEFT) + self.sigma_label = tk.Label(self.analize_frame, text="シグマ(輪郭の円滑性)") + self.sigma_label.pack(side=tk.LEFT, padx=(20, 0)) + self.sigma_text = tk.Entry(self.analize_frame, width=5, justify=tk.RIGHT) + self.sigma_text.insert(tk.END, "5.0") + self.sigma_text.pack(side=tk.LEFT) # 画像表示 self.canvas = tk.Canvas(self.tkroot, bg="black") @@ -59,13 +64,16 @@ self.tkroot.mainloop() + # 分析 def analyze(self): interval = int(self.interval_text.get()) - self.lp.profiling(interval) + ratio = float(self.area_ratio_text.get()) / 100 + sigma = float(self.sigma_text.get()) + self.lp.profiling(ratio, sigma, interval) self.time_slider.config(to=len(self.lp.results) - 1) self.time_slider.set(0) - self.show_image() self.is_analyzed = True + self.show_image() # 映像ファイルを開く def open_movie(self): diff --git a/lumen_profiler.py b/lumen_profiler.py index 36f583a..c9e0ed6 100644 --- a/lumen_profiler.py +++ b/lumen_profiler.py @@ -21,11 +21,11 @@ self.frame_count = len(self.frames) cap.release() - def profiling(self, area_ratio, step=1): + def profiling(self, area_ratio, sigma, step=1): self.results = [] for idx in range(0, len(self.frames), step): frame = self.frames[idx] - mask = self.lumen_mask(frame, area_ratio) + mask = self.lumen_mask(frame, area_ratio, sigma) circle_level, contour = self.calc_circle_level(mask) result = { "idx": idx, @@ -34,6 +34,7 @@ "circle_level": circle_level, "contour": contour, "ratio": area_ratio, + "sigma": sigma, } self.results.append(result) @@ -88,7 +89,7 @@ thres = i break # 気道のマスク生成 - val_img = cv2.GaussianBlur(val_img, (13, 13), sigma) + val_img = cv2.GaussianBlur(val_img, (25, 25), sigma) mask = cv2.threshold(val_img, thres, 255, cv2.THRESH_BINARY_INV)[1] # 連結部の解析