png2poly
png2poly(filename)
Export polylines from png image
Reads a png file and outputs a list of polylines that constitute the contours of the png, using marching squares. This is useful for generating 2D "realworld" data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
str
|
Path to png file |
required |
Returns:
Name | Type | Description |
---|---|---|
poly |
list of numpy double arrays
|
Each list element is a matrix of ordered polyline vertex coordinates |
Notes
This often results in "duplicate" polylines (one is the white->black contour, other is the black->white contour.
Examples:
from gpytoolbox import png2poly
filename = "test/unit_tests_data/poly.png"
poly = png2poly(filename)
Source code in src/gpytoolbox/png2poly.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
|