Skip to content
Snippets Groups Projects
Commit 297cc939 authored by Quentin Bolsee's avatar Quentin Bolsee
Browse files

skeleton code

parent 4b9bb32b
No related branches found
No related tags found
No related merge requests found
import cv2 import cv2
import numpy as np import numpy as np
try:
import trace_skeleton import trace_skeleton
use_swig = True
except ImportError:
import trace_skeleton_old
use_swig = False
import skimage.morphology import skimage.morphology
import random import random
...@@ -29,8 +34,11 @@ def stroke(img): ...@@ -29,8 +34,11 @@ def stroke(img):
im = skimage.morphology.skeletonize(img_binary).astype(np.uint8) im = skimage.morphology.skeletonize(img_binary).astype(np.uint8)
if use_swig:
polys = trace_skeleton.from_numpy(im)
else:
rects = [] rects = []
polys = trace_skeleton.traceSkeleton(im, 0, 0, im.shape[1], im.shape[0], 10, 999, rects) polys = trace_skeleton_old.traceSkeleton(im, 0, 0, im.shape[1], im.shape[0], 10, 999, rects)
for l in polys: for l in polys:
# c = (200 * random.random(), 200 * random.random(), 200 * random.random()) # c = (200 * random.random(), 200 * random.random(), 200 * random.random())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment