Ejemplo n.º 1
0
def preproc_open_curve(beta, T=100):
    n, M, k = beta.shape

    q = np.zeros((n, T, k))
    beta2 = np.zeros((n, T, k))
    for i in range(0, k):
        beta1 = fs.resamplecurve(beta[:, :, i], T)
        beta2[:, :, i] = beta1
        q[:, :, i] = fs.curve_to_q(beta1)

    return (q, beta2)
Ejemplo n.º 2
0
Disp_geodesic_between_the_curves = 1
Disp_registration_between_curves = 1

beta1 = C[:, :, 0]
beta2 = C[:, :, 2]
n, T = beta1.shape

beta1 = fs.resamplecurve(beta1, T)
beta2 = fs.resamplecurve(beta2, T)

centroid1 = fs.calculatecentroid(beta1)
beta1 = beta1 - np.tile(centroid1, [T, 1]).T
centroid2 = fs.calculatecentroid(beta2)
beta2 = beta2 - np.tile(centroid2, [T, 1]).T

q1 = fs.curve_to_q(beta1)

if rotation:
    beta2, O1, tau = fs.find_rotation_and_seed_coord(beta1, beta2)
    q2 = fs.curve_to_q(beta2)
else:
    O1 = np.eye(2)
    q2 = fs.curve_to_q(beta2)

if elastic:
    # Find the optimal coorespondence
    gam = fs.optimum_reparam_curve(q2, q1, lam)
    gamI = fs.invertGamma(gam)
    # Applying optimal re-parameterization to the second curve
    beta2n = fs.group_action_by_gamma_coord(beta2, gamI)
    q2n = fs.curve_to_q(beta2n)
Ejemplo n.º 3
0
import h5py
import fdasrsf as fs
import numpy as np
import matplotlib.pyplot as plt
fun = h5py.File('/Users/jdtucker/Documents/Research/SRVF_FDA/Data/Full20shapedata.h5')
C = fun['beta'][:]
C = C.T

a, b, c = C.shape
q = np.zeros((a, b, 20))
beta = np.zeros((a, b, 20))
for ii in range(0, 20):
    q[:, :, ii] = fs.curve_to_q(C[:, :, ii])
    beta[:, :, ii] = C[:, :, ii]

mu, betamean, v = fs.curve_karcher_mean(q, beta, mode='O')
K = fs.curve_karcher_cov(betamean, beta, mode='O')
pd = fs.curve_principal_directions(betamean, mu, K, mode='O', no=3, N=3)
samples = fs.sample_shapes(mu, K, mode='O', no=3, numSamp=10)
Ejemplo n.º 4
0
Disp_geodesic_between_the_curves = 1
Disp_registration_between_curves = 1

beta1 = C[:, :, 0]
beta2 = C[:, :, 2]
n, T = beta1.shape

beta1 = fs.resamplecurve(beta1, T)
beta2 = fs.resamplecurve(beta2, T)

centroid1 = fs.calculatecentroid(beta1)
beta1 = beta1 - np.tile(centroid1, [T, 1]).T
centroid2 = fs.calculatecentroid(beta2)
beta2 = beta2 - np.tile(centroid2, [T, 1]).T

q1 = fs.curve_to_q(beta1)

if rotation:
    beta2, O1, tau = fs.find_rotation_and_seed_coord(beta1, beta2)
    q2 = fs.curve_to_q(beta2)
else:
    O1 = np.eye(2)
    q2 = fs.curve_to_q(beta2)

if elastic:
    # Find the optimal coorespondence
    gam = fs.optimum_reparam_curve(q2, q1, lam)
    gamI = fs.invertGamma(gam)
    # Applying optimal re-parameterization to the second curve
    beta2n = fs.group_action_by_gamma_coord(beta2, gamI)
    q2n = fs.curve_to_q(beta2n)
Ejemplo n.º 5
0
import h5py
import fdasrsf as fs
import numpy as np
import matplotlib.pyplot as plt
fun = h5py.File(
    '/Users/jdtucker/Documents/Research/SRVF_FDA/Data/Full20shapedata.h5')
C = fun['beta'][:]
C = C.T

a, b, c = C.shape
q = np.zeros((a, b, 20))
beta = np.zeros((a, b, 20))
for ii in range(0, 20):
    q[:, :, ii] = fs.curve_to_q(C[:, :, ii])
    beta[:, :, ii] = C[:, :, ii]

mu, betamean, v = fs.curve_karcher_mean(q, beta, mode='O')
K = fs.curve_karcher_cov(betamean, beta, mode='O')
pd = fs.curve_principal_directions(betamean, mu, K, mode='O', no=3, N=3)
samples = fs.sample_shapes(mu, K, mode='O', no=3, numSamp=10)