That might be a question that is a little... big. I was inspired by that, and wonder if I can do it in python:
Following its idea, I first got the edge of the image, take it as a matrix and evaluated the position of the points, then try to make it continuous, like that (apparently not beautiful... ):
(If I don't do that, plot them by line willbe like this:)
Then I make fft to the x and y coordinates, got that:
[ 92897.00000000 +0.j -16312.65365042 -5708.43473681j
6403.02886691-11902.98323505j ...
I thought these number represents C_n below:
So I use these complex numbers, trying to construct an formula:
equ = ''
itera = 0
for comp in compList: # compList is the list of the complex numbers
mod = math.sqrt(comp.real**2 + comp.imag**2)
arg = cmath.phase(comp)
if not comp.imag == 0:
equ += '+' + str(mod) + '*np.sin(' + str(itera*2) + '*t+' +\
str(arg) + ')'
else:
equ += str(2 * comp.real)
itera += 1
Which gave me this:
185794.0+17282.618327763143*np.sin(2*t+-2.804972121911925)+13515.908721371954*np.sin(4*t+-1.0772633933209355)+11927.354784757847*np.sin(6*t+1.847507468889795)+...
I do an eval() to it, thinking that'll be the formula, the total code is like this :
x, y = getBorder('target.png', maxRes = 256)
x, y = sortNearest(x, y, maxDistance = 15)
fx = np.fft.fft(x)
fy = np.fft.fft(y)
equaX = generateEqua(fx) #the codes beyond
equaY = generateEqua(fy)
t = np.linspace(0, len(x), 10000)
fsX = eval(equaX)
fsY = eval(equaY)
fig = plt.figure(figsize = (15, 15))
plt.plot(fsX, fsY, linewidth = 0.5)
plt.show()
And that's what it gave: Apparently not what I want...
Here I am not asking for details, just wonder where might be incorrect, is my concept wrong?Lack something? Or I use some wrong options?