There are three tasks that I am required to do :
- Regularizing Curves
- Symmetry in Curves
- Completing Incomplete Curves
For example here are input and expected output images:
Input
output
In a general setting, shapes can be represented by any SVG curve primitive (Bezier, line, arcs). For the sake of uniform presentation, the examples contain polyline approximations of the curves. These polylines are saved as CSV files.
Here is the code for reading the CSV files:
import numpy as np
def read_csv ( csv_path ):
np_path_XYs = np . genfromtxt ( csv_path , delimiter = ’ , ’)
path_XYs = []
for i in np . unique ( np_path_XYs [: , 0]):
npXYs = np_path_XYs [ np_path_XYs [: , 0] == i ][: , 1:]
XYs = []
for j in np . unique ( npXYs [: , 0]):
XY = npXYs [ npXYs [: , 0] == j ][: , 1:]
XYs . append ( XY )
path_XYs . append ( XYs )
return path_XYs
This code will yield a list containing each shape. A shape is encoded as a list of paths, where each path is a numpy array of points defining the polyline. This is the following code to visualize the shapes:
import numpy as np
import matplotlib . pyplot as plt
def plot ( paths_XYs ):
fig , ax = plt . subplots ( tight_layout = True , figsize =(8 , 8))
for i , XYs in enumerate ( path_XYs ):
c = colours [ i % len( colours )]
for XY in XYs :
ax . plot ( XY [: , 0] , XY [: , 1] , c =c , linewidth =2)
ax . set_aspect ( ’ equal ’)
plt . show ()
Here is the .csv file to use as input:
input csv file
I wanna know if there are any libraries I can use to build this project ?
Any suggestions would be helpful