diff --git a/host/filtering.py b/host/filtering.py index 06bba2381829a14f272cee769d859abfce753cdd..7b40c840c0f4d017049451d3b377f9e51a440861 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)