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

Function polygonize

imagepy/tools/Standard/magic_tol.py:18–27  ·  view source on GitHub ↗
(conts, withholes = False)

Source from the content-addressed store, hash-verified

16import matplotlib.pyplot as plt
17
18def polygonize(conts, withholes = False):
19 for i in conts:i[:,[0,1]] = i[:,[1,0]]
20 polygon = Polygon(conts[0]).buffer(0)
21 if not withholes:return polygon
22 holes = []
23 for i in conts[1:]:
24 if len(i)<4:continue
25 holes.append(Polygon(i).buffer(0))
26 hole = cascaded_union(holes)
27 return polygon.difference(hole)
28
29
30class Plugin(Tool):

Callers 1

mouse_downMethod · 0.70

Calls 2

bufferMethod · 0.80
appendMethod · 0.80

Tested by

no test coverage detected