python - Converting numpy array svg image -
i have image want save in svg format. image in form of numpy array. although, there exist many methods save array in different image formats, not find 1 says done in svg.
any pointers or python script great!
thanks
since image in raster format, best can convert vector graphics program potrace. has python bindings pypotrace.
example code:
import numpy np import potrace # make numpy array rectangle in middle data = np.zeros((32, 32), np.uint32) data[8:32-8, 8:32-8] = 1 # create bitmap array bmp = potrace.bitmap(data) # trace bitmap path path = bmp.trace() # iterate on path curves curve in path: print "start_point =", curve.start_point segment in curve: print segment end_point_x, end_point_y = segment.end_point if segment.is_corner: c_x, c_y = segment.c else: c1_x, c1_y = segment.c1 c2_x, c2_y = segment.c2
Comments
Post a Comment