コード例 #1
0
ファイル: fig_datasets.py プロジェクト: 0todd0000/lmfree2d
plt.ion()
from matplotlib import patheffects
import pandas as pd
import lmfree2d as lm

#(0) Load data:
dirREPO = lm.get_repository_path()
names = [
    'Bell', 'Comma', 'Device8', 'Face', 'Flatfish', 'Hammer', 'Heart',
    'Horseshoe', 'Key'
]
R, LM = [], []
for name in names:
    fnameXY = os.path.join(dirREPO, 'Data', name, 'contours.csv')
    fnameLM = os.path.join(dirREPO, 'Data', name, 'landmarks.csv')
    r = lm.read_csv(fnameXY)
    frame = pd.read_csv(fnameLM, sep=',')
    R.append(r)
    LM.append(frame)
templates = [0, 2, 0, 0, 0, 8, 1, 0, 0]

#(1) Plot:
plt.close('all')
plt.figure(figsize=(14, 10))
axx = np.linspace(0, 1, 4)[:3]
axy = np.linspace(0.95, 0, 4)[1:]
axw = axx[1] - axx[0]
axh = axy[0] - axy[1]
AX = np.array([[plt.axes([xx, yy, axw, axh]) for xx in axx] for yy in axy])
ax0, ax1, ax2, ax3, ax4, ax5, ax6, ax7, ax8 = AX.flatten()
コード例 #2
0
ファイル: fig_corresp.py プロジェクト: 0todd0000/lmfree2d
import os
import numpy as np
from matplotlib import pyplot as plt
plt.ion()
import lmfree2d as lm

#(0) Load data:
dirREPO = lm.get_repository_path()
names = [
    'Bell', 'Comma', 'Device8', 'Face', 'Flatfish', 'Hammer', 'Heart',
    'Horseshoe', 'Key'
]
name = names[0]
fnameCSV = os.path.join(dirREPO, 'Data', name, 'contours_sroc.csv')
r = lm.read_csv(fnameCSV)
i0, i1 = 1, 2
r0, r1 = r[i0], r[i1]

#(1) Process:
np.random.seed(0)
### shuffle:
rA0, rA1 = lm.shuffle_points(r0), lm.shuffle_points(r1)
### reorder:
rB0, rB1 = [
    lm.reorder_points(r, optimum_order=True, ensure_clockwise=True)
    for r in [rA0, rA1]
]
### optimum roll correspondence:
rD0 = rB0.copy()
rD1 = lm.corresp_roll(rB1, rB0)
コード例 #3
0
import os
import numpy as np
from matplotlib import pyplot as plt
plt.ion()
from matplotlib import patheffects
import lmfree2d as lm

#(0) Load data:
dirREPO = lm.get_repository_path()
names = [
    'Bell', 'Comma', 'Device8', 'Face', 'Flatfish', 'Hammer', 'Heart',
    'Horseshoe', 'Key'
]
R = [
    lm.read_csv(os.path.join(dirREPO, 'Data', name, 'contours_sr.csv'))
    for name in names
]
templates = [0, 2, 0, 0, 0, 8, 1, 0, 0]

#(1) Plot:
plt.close('all')
lm.set_matplotlib_rcparams()
plt.figure(figsize=(14, 10))
axx = np.linspace(0, 1, 4)[:3]
axy = np.linspace(0.95, 0, 4)[1:]
axw = axx[1] - axx[0]
axh = axy[0] - axy[1]
AX = np.array([[plt.axes([xx, yy, axw, axh]) for xx in axx] for yy in axy])
ax0, ax1, ax2, ax3, ax4, ax5, ax6, ax7, ax8 = AX.flatten()
コード例 #4
0
ファイル: fig_sensitivity.py プロジェクト: 0todd0000/lmfree2d
    rtemp1 = r2[i]
    r3 = lm.set_npoints(r2, n)
    r4 = lm.corresp_roll(r3, rtemp1)
    return r4, rtemp1


#(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)
コード例 #5
0
	x0,x1  = ax.get_xlim()
	y0,y1  = ax.get_ylim()
	h      = [ax.plot([x1+1,x1+2,x1+3], [y1+1,y1+2,y1+3], ls, color=color, linewidth=lw, markerfacecolor=mfc)[0]   for color,ls,lw,mfc in zip(colors,linestyles,linewidths,markerfacecolors)]
	ax.set_xlim(x0, x1)
	ax.set_ylim(y0, y1)
	return ax.legend(h, labels, **kwdargs)
	



#(0) Load results:
dirREPO      = lm.get_repository_path()
names        = ['Bell', 'Comma', 'Device8', 'Face',    'Flatfish', 'Hammer', 'Heart', 'Horseshoe', 'Key']
spm_results  = [lm.read_csv_spm(  os.path.join(dirREPO, 'Data', name, 'spm.csv')  )   for name in names]
snpm_results = [lm.read_csv_spm(  os.path.join(dirREPO, 'Data', name, 'snpm.csv')  )   for name in names]
contours     = [lm.read_csv(  os.path.join(dirREPO, 'Data', name, 'contours_sroc.csv')  )   for name in names]



#(1) Plot:
plt.close('all')
lm.set_matplotlib_rcparams()
plt.figure(figsize=(14,10))
# create axes:
axx = np.linspace(0, 1, 4)[:3]
axy = np.linspace(0.95, 0, 4)[1:]
axw = axx[1]-axx[0]
axh = axy[0]-axy[1]
AX  = np.array([[plt.axes([xx,yy,axw,axh])  for xx in axx] for yy in axy])
# specify constants:
fc0,fc1   = '0.7', '0.9'