Example #1
0
def fit_ThinPlateSpline_RotReg(x_na, y_ng, bend_coef = .1, rot_coefs = (0.01,0.01,0.0025),scale_coef=.01):
    import fastrapp
    f = ThinPlateSpline()
    rfunc = fastrapp.rot_reg
    fastrapp.set_coeffs(rot_coefs, scale_coef)
    f.lin_ag, f.trans_g, f.w_ng = tps.tps_fit_regrot(x_na, y_ng, bend_coef, rfunc)
    f.x_na = x_na
    return f        
Example #2
0
def fit_ThinPlateSpline_RotReg(x_na, y_ng, bend_coef = .1, rot_coefs = (0.01,0.01,0.0025),scale_coef=.01):
    import fastrapp
    f = ThinPlateSpline()
    rfunc = fastrapp.rot_reg
    fastrapp.set_coeffs(rot_coefs, scale_coef)
    f.lin_ag, f.trans_g, f.w_ng = tps.tps_fit_regrot(x_na, y_ng, bend_coef, rfunc)
    f.x_na = x_na
    return f        
Example #3
0
def fit_ThinPlateSpline_RotReg(x_na, y_ng, bend_coef = .1, wt_n=None, rot_coefs = (0.01,0.01,0.0025),scale_coef=.01, niter_powell=100):
    import fastrapp
    f = ThinPlateSpline()
    rfunc = fastrapp.rot_reg
    fastrapp.set_coeffs(rot_coefs, scale_coef)
    f.lin_ag, f.trans_g, f.w_ng = tps.tps_fit_regrot(x_na, y_ng, bend_coef, rfunc, wt_n, max_iter=niter_powell)
    f.x_na = x_na
    return f        
Example #4
0
def tps_regrot_with_quad_cost():
    x_na = np.random.randn(100,3)
    y_ng = np.random.randn(100,3)
    bend_coef = .1
    rot_coef = 19
    def rfunc(b):
        return rot_coef*((b - np.eye(3))**2).sum()
    correct_lin_ag, correct_trans_g, correct_w_ng = tps.tps_fit2(x_na, y_ng, bend_coef, rot_coef)
    lin_ag, trans_g, w_ng = tps.tps_fit_regrot(x_na, y_ng, bend_coef, rfunc, max_iter=20)
    assert np.allclose(correct_trans_g, trans_g, atol=1e-2)    
    assert np.allclose(correct_lin_ag, lin_ag, atol=1e-2)
    assert np.allclose(correct_w_ng, w_ng,atol=1e-2)
Example #5
0
def tps_regrot_with_quad_cost():
    x_na = np.random.randn(100, 3)
    y_ng = np.random.randn(100, 3)
    bend_coef = .1
    rot_coef = 19

    def rfunc(b):
        return rot_coef * ((b - np.eye(3))**2).sum()

    correct_lin_ag, correct_trans_g, correct_w_ng = tps.tps_fit2(
        x_na, y_ng, bend_coef, rot_coef)
    lin_ag, trans_g, w_ng = tps.tps_fit_regrot(x_na,
                                               y_ng,
                                               bend_coef,
                                               rfunc,
                                               max_iter=20)
    assert np.allclose(correct_trans_g, trans_g, atol=1e-2)
    assert np.allclose(correct_lin_ag, lin_ag, atol=1e-2)
    assert np.allclose(correct_w_ng, w_ng, atol=1e-2)