From 863ec72026a1c63b8f3e4fc46aae57e24e0f71a0 Mon Sep 17 00:00:00 2001 From: Quentin Bolsee <quentinbolsee@hotmail.com> Date: Thu, 14 Dec 2023 13:27:18 -0500 Subject: [PATCH] code --- host/filtering.py | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/host/filtering.py b/host/filtering.py index 06bba23..7b40c84 100644 --- a/host/filtering.py +++ b/host/filtering.py @@ -1,7 +1,7 @@ import cv2 import numpy as np -import matplotlib.pyplot as plt import trace_skeleton +import skimage.morphology import random @@ -21,26 +21,13 @@ def bf(img): return edges -# def stroke(img): -# img_float = img.astype(np.float32) / 255.0 -# img_binary = img_float < 0.5 -# out_thin = morphology.thin(img_binary) -# out_skeletonize = morphology.skeletonize(img_binary) -# plt.figure() -# plt.imshow(out_skeletonize) -# plt.show() -# -# contours = measure.find_contours(out_thin, 0.7) -# return contours - - def stroke(img): img_copy = np.ones_like(img)*255 img2 = bf(img) img_float = img2.astype(np.float32) / 255.0 img_binary = img_float > 0.5 - im = trace_skeleton.thinning(img_binary) + im = skimage.morphology.skeletonize(img_binary).astype(np.uint8) rects = [] polys = trace_skeleton.traceSkeleton(im, 0, 0, im.shape[1], im.shape[0], 10, 999, rects) -- GitLab