MCPcopy Create free account
hub / github.com/Image-Py/imagepy / cut

Function cut

imagepy/tools/Network/graphcut_tol.py:36–54  ·  view source on GitHub ↗
(img, lines)

Source from the content-addressed store, hash-verified

34 if cur==s:break
35
36def cut(img, lines):
37 if len(lines)<2:return
38 lines = np.array(lines).round()
39 ox,oy = lines[0]
40 for i in lines[1:]:
41 cx, cy = i
42 dx, dy = cx-ox, cy-oy
43 n = max(abs(dx), abs(dy)) + 1
44 xs = np.linspace(cx, ox, n).round().astype(np.int16)
45 ys = np.linspace(cy, oy, n).round().astype(np.int16)
46 for x,y in zip(xs, ys):
47 for dxy in [(1,0),(0,1)]:
48 xx = x + dxy[0]
49 yy = y + dxy[1]
50 if xx<0 or xx>img.shape[1]: continue
51 if yy<0 or yy>img.shape[0]: continue
52 if img[yy,xx] == 0: continue
53 floodfill(img, xx, yy)
54 ox, oy = i
55
56class Mark():
57 def __init__(self, line):

Callers 1

mouse_upMethod · 0.85

Calls 1

floodfillFunction · 0.70

Tested by

no test coverage detected