Exemple #1
0
        os.mkdir(font_name)

    sans_S = []
    serif_S = []


    fout = file(font_name + "/results.txt", 'w')

    other_letters = [fn for fn in letters if not fn == test_letter_file]

    for letter_file in other_letters:
    
    
        letter = np.genfromtxt(letter_file, unpack=True)

        o = img.minimize(M=M,N=N,qA=test_letter, qB=letter, alpha=alpha,sigma= sigma)


        fout.write("%s ----- S=%10.5f\n" %(letter_file,o[0][1]))

        if re.search("sans-",letter_file):
            sans_S.append(o[0][1])
        else:
            serif_S.append(o[0][1])

        o[1].plot_steps_held()

        pdfname = letter_file.replace(".txt",".pdf")
        
        
        plt.savefig(font_name + "/" + pdfname.split('/').pop(),bbox_inches='tight')
M, N = 100, 10

sigma = 0.001
alpha = 0.001

# try with this hand drawn star
tmpl = np.genfromtxt("shape_match/test_star.txt", unpack=True)


results = []

for shape_file in glob.glob("shape_match/*.txt"):
    if not re.search('test_',shape_file):
        targ = np.genfromtxt(shape_file, unpack=True)

        o = img.minimize(M=M,N=N,qA=tmpl, qB=targ, alpha=alpha, sigma=sigma)

        results.append([[shape_file, o[0][1]], o])

        o[1].plot_steps_held()
        plt.savefig(shape_file.replace(".txt",".pdf"),bbox_inches='tight')

        print shape_file, o[0][1] #, o[0][1]


match = None

for res in results:
    if match is None:
        match = res
    else:
import os, sys
lib_path = os.path.abspath('../')
sys.path.append(lib_path)

import image_deformation as img
import drawcurve

import numpy as np

""" 
You can draw two curves and then find the deformation between them. 
It's best to run this in ipython to inspect results further, make other plots
"""

M, N = 100, 10

vs = img.template_size(M=M, N=N)

tmpl = drawcurve.get_vec(vs, "Draw template")
targ = drawcurve.get_vec(vs, "Draw target")

opt = img.minimize(M=M, N=N, qA=tmpl, qB=targ)

im = opt[1]

im.plot_steps()