Esempio n. 1
0
def process_data(r0):
    r0 = lm.shuffle_points(r0)
    ### CPD registration
    rtemp0, n, i = lm.get_shape_with_most_points(r0)
    r1 = lm.register_cpd(r0, rtemp0)
    ### reorder points:
    r2 = lm.reorder_points(r1, optimum_order=True, ensure_clockwise=True)
    ### correspondence:
    rtemp1 = r2[i]
    r3 = lm.set_npoints(r2, n)
    r4 = lm.corresp_roll(r3, rtemp1)
    return r4, rtemp1
Esempio n. 2
0
    fnameSPM = os.path.join(dirREPO, 'Data', name, 'spm.csv')
    fnameSnPM = os.path.join(dirREPO, 'Data', name, 'snpm.csv')

    ### load data
    r0 = lm.read_csv(fname0)

    ### shuffle contour points:
    print('Shuffling contour points...')
    np.random.seed(10 + names.index(name))
    r1 = lm.shuffle_points(r0)
    lm.write_csv(fname1, r1)

    ### CPD registration
    print('Registering using CPD...')
    rtemp0, n, i = lm.get_shape_with_most_points(r1)
    r2 = lm.register_cpd(r1, rtemp0)
    lm.write_csv(fname2, r2)

    ### reorder points:
    print('Re-ordering points...')
    r3 = lm.reorder_points(r2, optimum_order=True, ensure_clockwise=True)
    lm.write_csv(fname3, r3)

    ### correspondence:
    print('Running correspondence algorithm...')
    rtemp1 = r3[i]
    r4 = lm.set_npoints(r3, n)
    r4 = lm.corresp_roll(r4, rtemp1)
    lm.write_csv(fname4, r4)

    ### hypothesis test:
Esempio n. 3
0

#(0) Process data:
### load data
dirREPO = lm.get_repository_path()
names = [
    'Bell', 'Comma', 'Device8', 'Face', 'Flatfish', 'Hammer', 'Heart',
    'Horseshoe', 'Key'
]
name = names[6]
fname0 = os.path.join(dirREPO, 'Data', name, 'contours.csv')
r0 = lm.read_csv(fname0)
r0 = lm.shuffle_points(r0)
### CPD registration
rtemp0, n, i = lm.get_shape_with_most_points(r0)
r1 = lm.register_cpd(r0, rtemp0)
### reorder points:
r2 = lm.reorder_points(r1, optimum_order=True, ensure_clockwise=True)
### correspondence:
rtemp1 = r2[i]
r3 = lm.set_npoints(r2, n)
r4 = lm.corresp_roll(r3, rtemp1)
### process data:
np.random.seed(0)  # Case 1
r1, rtemp1 = process_data(r0)
np.random.seed(2)  # Case 2
r2, rtemp2 = process_data(r0)
### hypothesis tests:
rA1, rB1 = r1[:5], r1[5:]
rA2, rB2 = r2[:5], r2[5:]
results1 = lm.two_sample_test(rA1, rB1, parametric=True)
Esempio n. 4
0
import os
import numpy as np
from matplotlib import pyplot as plt
plt.ion()
import lmfree2d as lm




#(0) Load results:
dirREPO    = lm.get_repository_path()
fname0     = os.path.join(dirREPO, 'Data', '_ExampleCPD', 'contour0.csv')
fname1     = os.path.join(dirREPO, 'Data', '_ExampleCPD', 'contour1.csv')
r0         = np.loadtxt(fname0, delimiter=',', skiprows=1)
r1         = np.loadtxt(fname1, delimiter=',', skiprows=1)
r1r        = lm.register_cpd(r0, r1)



#(1) Plot:
plt.close('all')
lm.set_matplotlib_rcparams()
plt.figure(figsize=(6,4))
axw   = 0.47
axh   = 0.90
ax0   = plt.axes([0,0,axw,axh])
ax1   = plt.axes([1-axw,0,axw,axh])
c0,c1 = lm.colors[[2,5]]

ax0.plot(r0[:,0], r0[:,1], 'o', ms=4, color=c0)
ax0.plot(r1[:,0], r1[:,1], 'o', ms=4, color=c1)