This notebook regroups different visual tests to check for the computation of edge co-occurences.
%load_ext autoreload
%autoreload 2
import matplotlib
#matplotlib.rcParams.update({'font.size': 18, 'font.family': 'STIXGeneral', 'mathtext.fontset': 'stix'})
matplotlib.rcParams.update({'text.usetex': False})
%matplotlib inline
%config InlineBackend.figure_format='retina'
import matplotlib.pyplot as plt
import numpy as np
np.set_printoptions(precision=4)#, suppress=True)
# http://ipython.org/ipython-doc/stable/config/extensions/autoreload.html
#%load_ext autoreload
#%autoreload 2
# where should we store the figures generated by this notebook
figpath = ''
%cd -q ../probe
from SparseEdges import SparseEdges
mp = SparseEdges('https://raw.githubusercontent.com/bicv/SparseEdges/master/default_param.py')
mp.pe.N = 4
mp.pe.do_mask = False
mp.pe.MP_alpha = 1.
mp.pe.do_whitening = False
mp.init()
print ('Range of spatial frequencies: ', mp.sf_0)
Range of spatial frequencies: [0.4545 0.2935 0.1895 0.1224 0.079 0.051 0.0329 0.0213 0.0137 0.0089 0.0057]
help(SparseEdges.cooccurence)
Help on function cooccurence in module SparseEdges.SparseEdges: cooccurence(self, edges_ref, edges_comp=None, symmetry=True)
help(SparseEdges.cooccurence_hist)
Help on function cooccurence_hist in module SparseEdges.SparseEdges: cooccurence_hist(self, edges_ref, edges_comp=None, symmetry=True, mode='full')
print ('Range of angles: ', mp.theta*180./np.pi)
Range of angles: [-82.5 -75. -67.5 -60. -52.5 -45. -37.5 -30. -22.5 -15. -7.5 0. 7.5 15. 22.5 30. 37.5 45. 52.5 60. 67.5 75. 82.5 90. ]
NOTE: everything below this point should go to another notebook
from SparseEdges import SparseEdges
mp = SparseEdges('https://raw.githubusercontent.com/bicv/SparseEdges/master/default_param.py')
mp.pe.figsize_edges = 12
print (mp.pe)
{'verbose': 0, 'N_image': None, 'seed': 42, 'N_X': 256, 'N_Y': 256, 'noise': 0.33, 'do_mask': True, 'mask_exponent': 3.0, 'do_whitening': True, 'white_name_database': 'kodakdb', 'white_n_learning': 0, 'white_N': 0.07, 'white_N_0': 0.0, 'white_f_0': 0.4, 'white_alpha': 1.4, 'white_steepness': 4.0, 'white_recompute': False, 'base_levels': 1.618, 'n_theta': 24, 'B_sf': 0.4, 'B_theta': 0.17453277777777776, 'N': 2048, 'MP_alpha': 0.7, 'd_width': 45.0, 'd_min': 0.5, 'd_max': 2.0, 'N_r': 6, 'N_Dtheta': 24, 'N_phi': 12, 'N_scale': 5, 'loglevel_max': 7.0, 'edge_mask': False, 'do_rank': False, 'scale_invariant': True, 'multiscale': False, 'kappa_phase': 0.0, 'weight_by_distance': True, 'svm_n_jobs': 1, 'svm_test_size': 0.2, 'N_svm_grid': 32, 'N_svm_cv': 50, 'C_range_begin': -5, 'C_range_end': 10.0, 'gamma_range_begin': -14, 'gamma_range_end': 3, 'svm_KL_m': 0.34, 'svm_tol': 0.001, 'svm_max_iter': -1, 'svm_log': False, 'svm_norm': False, 'figpath': 'results', 'do_edgedir': False, 'do_indepcheck': False, 'edgefigpath': 'results/edges', 'matpath': 'cache_dir', 'edgematpath': 'cache_dir/edges', 'datapath': 'database', 'figsize': 14.0, 'figsize_hist': 8, 'figsize_cohist': 8, 'formats': ['png', 'pdf', 'jpg'], 'dpi': 450, 'use_cache': True, 'scale': 0.8, 'scale_circle': 0.08, 'scale_chevrons': 2.5, 'line_width': 1.0, 'line_width_chevrons': 0.75, 'edge_scale_chevrons': 180.0, 'figsize_edges': 12}
mp.pe.n_levels = np.log2(mp.pe.N_X)
cardinal points in X, Y (clockwise): E (=right=3 o'clock=horizontal), ESE, S, WSW, W, WNW, N, ENE
X = np.array([0, 1./4, 1./2, 1./4, 0, -1./4, -1./2])#, -1./4])\n",
Y = np.array([1./2, np.sqrt(3)/4, 0, -np.sqrt(3)/4, -1./2, -np.sqrt(3)/4, 0.])#, np.sqrt(3)/
Theta = np.arctan2(-X, Y)
Theta = ((Theta + np.pi/2 - np.pi/mp.pe.N_phi/2 ) % (np.pi)) - np.pi/2 + np.pi/mp.pe.N_phi/2
print (Theta* 180./np.pi)
[-4.7708e-15 -3.0000e+01 9.0000e+01 3.0000e+01 -4.7708e-15 -3.0000e+01 9.0000e+01]
The X, Y image axis are defined in the matrix style (origin on the upper left; X going vertically down, Y going right horizontally) - the angle is defined as the angle wrt to the horizontal axis :
fig, a = mp.show_edges(np.vstack(((X/2. + .5)*mp.pe.N_X, (Y/2. + .5)*mp.pe.N_X, Theta, .01*np.ones(X.shape), np.ones(X.shape), np.zeros(X.shape) )))
t = [a.text(Y_, X_, np.str((X_, Y_, angle*180/np.pi))) for (X_, Y_, angle) in zip((X/2. + .5)*mp.pe.N_X, (Y/2. + .5)*mp.pe.N_X, Theta)]
# test points
X = np.array([0.25, 0.25, 0.75])
Y = np.array([0.25, 0.75, 0.25])
X, Y = X*mp.pe.N_X, Y*mp.pe.N_X
print ('coord = ', X, Y)
# by definition, theta = 0 is the horizontal
Theta = np.array([0., np.pi/4, np.pi/2])
print ('angle (CCW wrt horizontal) =', Theta * 180./np.pi)
Sf_0, Weights, Phases = .01*np.ones(X.shape), np.ones(X.shape), np.ones(X.shape)
fig, a = mp.show_edges(np.vstack((X, Y, Theta, Sf_0, Weights, Phases)))
#t = [a.text(Y_, X_, np.str((X_, Y_, '%0.3f ' % (angle*180/np.pi), i))) for (X_, Y_, angle, i) in zip((X/2. + .5)*N_X, (Y/2. + .5)*N_Y, Theta, range(3))]
t = [a.text(Y_, X_, np.str(i)) for (X_, Y_, i) in zip(X, Y, range(3))]
coord = [ 64. 64. 192.] [ 64. 192. 64.] angle (CCW wrt horizontal) = [ 0. 45. 90.]
dx = X[:, np.newaxis] - X[np.newaxis, :]
dy = Y[:, np.newaxis] - Y[np.newaxis, :]
print ('dx_ij = \n', dx, '\n dy_ij = \n', dy)
dx_ij = [[ 0. 0. -128.] [ 0. 0. -128.] [ 128. 128. 0.]] dy_ij = [[ 0. -128. 0.] [ 128. 0. 128.] [ 0. -128. 0.]]
d = np.sqrt(dx**2 + dy**2) #/ pe.N_X * pe.d_width # distance in visual angle
print( np.diag(d), d[0, :])
plt.matshow(d); plt.colorbar()
[0. 0. 0.] [ 0. 128. 128.]
<matplotlib.colorbar.Colorbar at 0x108876160>
theta = Theta[:, np.newaxis] - Theta[np.newaxis, :]
print ('angle to self = ', np.diag(theta), '\nangle from 2 to ...= ', theta[2, :]*180/np.pi)
plt.matshow(theta*180/np.pi); plt.colorbar(ticks=np.linspace(-90, 90, 5))
print (theta*180/np.pi)
angle to self = [0. 0. 0.] angle from 2 to ...= [90. 45. 0.] [[ 0. -45. -90.] [ 45. 0. -45.] [ 90. 45. 0.]]
theta = ((theta + np.pi/2 - np.pi/mp.pe.N_Dtheta/2) % (np.pi) ) - np.pi/2 + np.pi/mp.pe.N_Dtheta/2
plt.matshow(theta*180/np.pi); plt.colorbar(ticks=np.linspace(-90, 90, 5))
print (np.diag(theta).std(), theta.min()*180/np.pi, theta.max()*180/np.pi)
print (theta*180/np.pi)
0.0 -45.0 90.0 [[ 3.9757e-15 -4.5000e+01 9.0000e+01] [ 4.5000e+01 3.9757e-15 -4.5000e+01] [ 9.0000e+01 4.5000e+01 3.9757e-15]]
# still anti-symmetric (theta == - theta.T)
plt.matshow(np.sin(theta + theta.T)); plt.colorbar()
<matplotlib.colorbar.Colorbar at 0x10df264a8>
phi is the azimuth of the other edge wrt a reference, the matrix gives phi_ij = phi of j wrt i
print ((np.arctan2(dy, dx) - np.pi/2)*180/np.pi, Theta*180/np.pi)
#np.seterr(all='ignore')
phi = (np.arctan2(dy, dx) - np.pi/2 - Theta[np.newaxis, :] + np.pi ) % (2*np.pi) - np.pi
phi += np.diag(np.nan*np.ones(3))
#print np.isnan(phi)
#phi[np.isnan(phi)] = 0.
print( phi*180/np.pi)# np.diag(phi, 1)*180/np.pi, phi[0, :]*180/np.pi
plt.matshow(phi*180/np.pi); plt.colorbar(ticks=np.linspace(-90, 90, 5))
[[ -90. -180. 90.] [ 0. -90. 45.] [ -90. -135. -90.]] [ 0. 45. 90.] [[ nan 135. 0.] [ 0. nan -45.] [ -90. -180. nan]]
<matplotlib.colorbar.Colorbar at 0x10f1e0dd8>
# not symmetric
plt.matshow(np.sin(phi - phi.T)); plt.colorbar()
<matplotlib.colorbar.Colorbar at 0x10f1c1b38>
theta = Theta[:, np.newaxis] - Theta[np.newaxis, :]
phi = np.arctan2(dy, dx) - np.pi/2 - Theta[np.newaxis, :]
phi += np.diag(np.nan*np.ones(3))
psi = phi - theta/2
#psi = (Theta[:, np.newaxis]+Theta[np.newaxis, :])/2 + np.arctan2(-dx, dy)# + np.pi/2
print( psi*180/np.pi)#, (psi - (psi + psi.T)/2)*180/np.pi
plt.matshow(psi*180/np.pi); plt.colorbar()
[[ nan -202.5 45. ] [ -22.5 nan -22.5] [-135. -202.5 nan]]
<matplotlib.colorbar.Colorbar at 0x10f36e470>
# symmetric
plt.matshow(np.sin(psi - psi.T)); plt.colorbar()
<matplotlib.colorbar.Colorbar at 0x10f4bcb00>
if we assume that an angle occurrence may also happen wrt to its mirror symetric (flipping left and right), then $\psi$ becomes non-oriented
# putting everything in the right range:
psi = ((psi + np.pi/2 - np.pi/mp.pe.N_phi/2 ) % (np.pi)) - np.pi/2 + np.pi/mp.pe.N_phi/2
print (psi*180/np.pi)
plt.matshow(psi*180/np.pi); plt.colorbar()
# still symmetric
plt.matshow(psi - psi.T); plt.colorbar()
#print np.sin(psi - psi.T).std()
[[ nan -22.5 45. ] [-22.5 nan -22.5] [ 45. -22.5 nan]]
<matplotlib.colorbar.Colorbar at 0x10f6129e8>
level = np.log2(Sf_0[:, np.newaxis]) - np.log2(Sf_0[np.newaxis, :])
plt.matshow(level); plt.colorbar()
<matplotlib.colorbar.Colorbar at 0x10e55b128>
weights = Weights[:, np.newaxis] * Weights[np.newaxis, :]
plt.matshow(weights); plt.colorbar()
weights /= (d + 1.e-6)
plt.matshow(weights); plt.colorbar()
<matplotlib.colorbar.Colorbar at 0x10e8044a8>
weights[d==0.] = 0. # exclude self-occurence
plt.matshow(weights); plt.colorbar()
<matplotlib.colorbar.Colorbar at 0x10e8570f0>
help( SparseEdges.histedges_theta)
help( SparseEdges.histedges_scale)
help( SparseEdges.cohistedges)
Help on function histedges_theta in module SparseEdges.SparseEdges: histedges_theta(self, edgeslist, mp_theta=None, v_hist=None, fig=None, ax=None, figsize=None, display=True) First-order stats p(theta | I ) Help on function histedges_scale in module SparseEdges.SparseEdges: histedges_scale(self, edgeslist, fig=None, ax=None, display=True) First-order stats for the scale p(scale | I ) Help on function cohistedges in module SparseEdges.SparseEdges: cohistedges(self, edgeslist, v_hist=None, prior=None, fig=None, ax=None, symmetry=True, display='chevrons', v_min=None, v_max=None, labels=True, mappable=False, radius=None, xticks=False, half=False, dolog=True, color='redblue', colorbar=True, cbar_label=True) second-order stats= center all edges around the current one by rotating and scaling p(x-x_, y-y_, theta-theta_ | I, x_, y_, theta_)
def myplot(edgeslist, mp):
"""
a function to display edges
"""
fig = plt.figure(figsize=(9, 12))
a1 = fig.add_subplot(321)
fig, a = mp.show_edges(edgeslist[:, :, 0], image=np.ones((mp.pe.N_X, mp.pe.N_X)), fig=fig, ax=a1)
a2 = fig.add_subplot(322)
fig, a2 = mp.histedges_scale(edgeslist, fig=fig, ax=a2)
a3 = fig.add_subplot(323, polar=True)
fig, a3 = mp.histedges_theta(edgeslist, fig=fig, ax=a3)
a4 = fig.add_subplot(324)
v_hist = mp.cohistedges(edgeslist, display='none')
v_hist_nosym = mp.cohistedges(edgeslist, display='none', symmetry=False)
fig, a4 = mp.cohistedges(edgeslist=None, v_hist=v_hist, fig=fig, ax=a4)
a5 = fig.add_subplot(325)
fig, a5 = mp.cohistedges(edgeslist=None, v_hist=v_hist_nosym, fig=fig, ax=a5, symmetry=False, display='colin_geisler')
a6 = fig.add_subplot(326)
fig, a6 = mp.cohistedges(edgeslist=None, v_hist=v_hist_nosym, fig=fig, ax=a6, symmetry=False, display='cocir_geisler')
#plt.tight_layout()
plt.show()
fig2 = plt.figure(figsize=(9, 9))
fig2, (a1, a2, a3, a4) = mp.cohistedges(edgeslist=None, v_hist=v_hist, fig=fig2, display='full')
return v_hist
mp = SparseEdges('https://raw.githubusercontent.com/bicv/SparseEdges/master/default_param.py')
mp.pe.N_image = 20
mp.pe.d_max = 2.
mp.pe.d_min = 0.
edgeslist = np.zeros((6, 2, mp.pe.N_image))
angle = np.pi/6
for i_N, sign in enumerate([-1., 1.]):
edgeslist[0, i_N, :] = mp.pe.N_X *(1/2. + .1 * np.sin(angle) * sign) + .0005 * np.random.randn(mp.pe.N_image)
edgeslist[1, i_N, :] = mp.pe.N_X *(1/2. - .1 * np.cos(angle) * sign) + .0005 * np.random.randn(mp.pe.N_image)
edgeslist[2, i_N, :] = (angle + np.pi/360.* np.random.randn(mp.pe.N_image)) % np.pi
edgeslist[3, i_N, :] = .03
edgeslist[4, i_N, :] = 1.
#print edgeslist
v_hist = myplot(edgeslist, mp=mp)
#print v_hist
edgeslist = np.zeros((6, 2, mp.pe.N_image))
angle = np.pi/6
for i_N, sign in enumerate([-1., 1.]):
edgeslist[0, i_N, :] = mp.pe.N_X *(1/2. + .1 * np.sin(angle) * sign) + .0005 * np.random.randn(mp.pe.N_image)
edgeslist[1, i_N, :] = mp.pe.N_X *(1/2. + .1 * np.cos(angle) * sign) + .0005 * np.random.randn(mp.pe.N_image)
edgeslist[2, i_N, :] = (angle + np.pi/360.* np.random.randn(mp.pe.N_image)) % np.pi
edgeslist[3, i_N, :] = .03
edgeslist[4, i_N, :] = 1.
#print edgeslist
_ = myplot(edgeslist, mp=mp)
edgeslist = np.zeros((6, 2, mp.pe.N_image))
angle = np.pi/6
for i_N, sign in enumerate([-1., 1.]):
edgeslist[0, i_N, :] = mp.pe.N_X *(1/2. + .1 * np.sin(angle) * sign) + .0005 * np.random.randn(mp.pe.N_image)
edgeslist[1, i_N, :] = mp.pe.N_X *(1/2. + .1 * np.cos(angle) * sign) + .0005 * np.random.randn(mp.pe.N_image)
edgeslist[2, i_N, :] = sign*(angle + np.pi/360.* np.random.randn(mp.pe.N_image)) % np.pi
edgeslist[3, i_N, :] = .03
edgeslist[4, i_N, :] = 1.
_ = myplot(edgeslist, mp=mp)
mp.pe.N = 512
print (mp.pe.base_levels, mp.n_levels)
edgeslist = np.zeros((6, mp.pe.N, mp.pe.N_image))
edgeslist[0, :, :] = mp.pe.N_X * np.random.rand(mp.pe.N, mp.pe.N_image)
edgeslist[1, :, :] = mp.pe.N_X * np.random.rand(mp.pe.N, mp.pe.N_image)
edgeslist[2, :, :] = ((np.pi* np.random.rand(mp.pe.N, mp.pe.N_image) ) % np.pi) - np.pi/2
edgeslist[3, :, :] = .03*np.ceil(mp.pe.base_levels**(mp.n_levels*(np.random.rand(mp.pe.N, mp.pe.N_image)+.5)))
edgeslist[4, :, :] = np.random.rand(mp.pe.N, mp.pe.N_image)
edgeslist[5, :, :] = 2*np.pi*np.random.rand(mp.pe.N, mp.pe.N_image)
_ = myplot(edgeslist, mp=mp)
1.618 11
edgeslist = np.zeros((6, mp.pe.N, mp.pe.N_image))
for i_N, x in enumerate(np.linspace(-mp.pe.N_X/4., mp.pe.N_X/4., mp.pe.N)):
edgeslist[0, i_N, :] = mp.pe.N_X * np.random.rand(mp.pe.N_image)
edgeslist[1, i_N, :] = mp.pe.N_X * np.random.rand(mp.pe.N_image)
edgeslist[2, i_N, :] = (np.pi/6 + np.pi/360.* np.random.randn(mp.pe.N_image) ) % np.pi
edgeslist[3, i_N, :] = mp.pe.base_levels**np.ceil(mp.n_levels*np.random.rand(mp.pe.N_image))
edgeslist[4, i_N, :] = np.random.randn(mp.pe.N_image)**2
#! show one sample
_ = myplot(edgeslist, mp=mp)
#print mp.cohistedges(edgeslist, display='none')
edgeslist = np.zeros((6, mp.pe.N, mp.pe.N_image))
for i_N, x in enumerate(np.linspace(-mp.pe.N_X/4., mp.pe.N_X/4., mp.pe.N)):
edgeslist[0, i_N, :] = mp.pe.N_X/2. + x + 1. * np.random.randn(mp.pe.N_image)
edgeslist[1, i_N, :] = mp.pe.N_X/2. + x + 1. * np.random.randn(mp.pe.N_image)
edgeslist[2, i_N, :] = ((-np.pi/4 + np.pi*5./180.* np.random.randn(mp.pe.N_image) ) % np.pi) - np.pi/2
edgeslist[3, i_N, :] = 32. #np.sqrt(2.)/2 * N_X / N
edgeslist[4, i_N, :] = 1.
_ = myplot(edgeslist, mp=mp)#
#! cocircular edges:
edgeslist = np.zeros((6, mp.pe.N, mp.pe.N_image))
#for i_N, angle in enumerate(np.linspace(0, 2*np.pi, N)):
for i_N, angle in enumerate(2*np.pi*np.random.rand(mp.pe.N)):
edgeslist[0, i_N, :] = mp.pe.N_X/2. - mp.pe.N_X/4.*np.sin(angle) + .5 * np.random.randn(mp.pe.N_image)
edgeslist[1, i_N, :] = mp.pe.N_X/2. + mp.pe.N_X/4.*np.cos(angle) + .5 * np.random.randn(mp.pe.N_image)
edgeslist[2, i_N, :] = ((np.pi + angle + .5*np.pi/180 * np.random.randn(mp.pe.N_image)) % np.pi) - np.pi/2
edgeslist[3, i_N, :] = 0.03
edgeslist[4, i_N, :] = 1.
_ = myplot(edgeslist, mp=mp)#
edgeslist = np.zeros((6, mp.pe.N, mp.pe.N_image))
#for i_N, angle in enumerate(np.linspace(0, 2*np.pi, pe.N)):
for i_N, angle in enumerate(2*np.pi*np.random.rand(mp.pe.N)):
edgeslist[0, i_N, :] = mp.pe.N_X/2. - .95*mp.pe.N_X/2.*np.sin(angle) + .05 * np.random.randn(mp.pe.N_image)
edgeslist[1, i_N, :] = mp.pe.N_X/2. + .95*mp.pe.N_X/2.*np.cos(angle) + .05 * np.random.randn(mp.pe.N_image)
edgeslist[2, i_N, :] = ((np.pi + angle + .5*np.pi/180 * np.random.randn(mp.pe.N_image)) % np.pi) - np.pi/2
edgeslist[3, i_N, :] = 0.03
edgeslist[4, i_N, :] = 1.
_ = myplot(edgeslist, mp=mp)
mp = SparseEdges('https://raw.githubusercontent.com/bicv/SparseEdges/master/default_param.py')
help( mp.run_mp)
Help on method run_mp in module SparseEdges.SparseEdges: run_mp(image, verbose=False, progress=False, progressfile=None) method of SparseEdges.SparseEdges.SparseEdges instance runs the MatchingPursuit algorithm on image
def full_hist(edgeslist, **kwargs):
v_hist = np.zeros((mp.pe.N_r, mp.pe.N_phi, mp.pe.N_Dtheta, mp.pe.N_scale, edgeslist.shape[2])) # bins=(self.edges_d, self.edges_phi, self.edges_theta, self.edges_loglevel)
for i_image in range(edgeslist.shape[2]):
v_hist[..., i_image] = mp.cohistedges(edgeslist[:, :, i_image][..., np.newaxis], display='none', **kwargs)
v_hist[..., i_image] /= v_hist[..., i_image].sum()
return v_hist
#! using first database
#print im.get_imagelist(exp='testing_vanilla', name_database='serre07_distractors')
#!ls mat/edges/testing_vanilla_serre07_distractors/
#edgeslist = np.load('../AssoField/mat/classifier_serre07_distractors_edges.npy')
mp.pe.datapath = '../../SLIP/database/'
imageslist, edgeslist, RMSE = mp.process(exp='Sparselets', name_database='serre07_distractors')
#_ = myplot(edgeslist[:, :, 0][:, :, np.newaxis], pe=pe)
import os
matname = os.path.join(mp.pe.matpath, 'Sparselets_serre07_distractors_hist.npy')
try:
v_hist = np.load(matname)
except Exception as e:
import os
if not(os.path.isfile(matname + '_lock')):
print( 'There is no histogram, creating one: ', e)
open(matname + '_lock', 'w').close() # touching
v_hist = myplot(edgeslist, mp=mp)
np.save(matname, v_hist)
os.remove(matname + '_lock')
else:
print (' Some process is building the histogram ' + matname )
imageslist, edgeslist, RMSE = mp.process(exp='testing_noise', name_database='serre07_distractors')
matname = os.path.join(mp.pe.matpath, 'testing_noise_vanilla_serre07_distractors_hist.npy')
try:
v_hist = np.load(matname)
except Exception as e:
if not(os.path.isfile(matname + '_lock')):
print ('There is no histogram, creating one: ', e)
open(matname + '_lock', 'w').close() # touching
v_hist = myplot(edgeslist, mp=mp)
np.save(matname, v_hist)
os.remove(matname + '_lock')
else:
print (' Some process is building the histogram ' + matname)
#edgeslist = np.load('../AssoField/mat/classifier_noise_serre07_targets_edges.npy')
#! show one sample
#fig, a = mp.show_edges(edgeslist[:, :, 0], image=None)
#v = pylab.axis((0, pe.N_X, pe.N_X, 0))
using second database
%ls ../probe/cache_dir/*_edges.npy
ls: ../probe/cache_dir/*_edges.npy: No such file or directory
using second database on one image
#imageslist, edgeslist, RMSE = mp.process(exp='testing_vanilla', name_database='serre07_targets')
#edgeslist = np.load('cache_dir/testing_vanilla_serre07_targets_edges.npy')
edgeslist = np.load('/Users/laurentperrinet/pool/science/PerrinetBednar15/test/cache_dir/edges/testing_vanilla_serre07_targets_edges.npy')
_ = myplot(edgeslist[:, :, 0][:, :, np.newaxis], mp=mp)
_ = myplot(edgeslist, mp=mp)
v_hist = mp.cohistedges(edgeslist, display='none')
#!rm mat/testing_vanilla_serre07_targets_hist.npy*
matname = os.path.join(mp.pe.matpath, 'testing_vanilla_serre07_targets_hist.npy')
try:
v_hist = np.load(matname)
except Exception as e:
if not(os.path.isfile(matname + '_lock')):
print ('There is no histogram, creating one: ', e)
open(matname + '_lock', 'w').close() # touching
v_hist = myplot(edgeslist, mp=mp)
np.save(matname, v_hist)
os.remove(matname + '_lock')
else:
print (' Some process is building the histogram ' + matname)
Note that the histogram is symmetric with respect to log-scales
mp.init_binedges()
print (mp.binedges_d.max())
print (v_hist.shape)
print (mp.binedges_loglevel)
2.0 (6, 12, 24, 5) [-7. -4.2 -1.4 1.4 4.2 7. ]
l_ = v_hist.sum(axis=(2, 1, 0))
print (l_, l_-l_[::-1])
[1.8971e-06 4.2025e-02 9.1595e-01 4.2025e-02 1.8971e-06] [0. 0. 0. 0. 0.]
print (np.sum(v_hist), np.sum((v_hist - v_hist[:, :, :, ::-1])**2))
0.9999999999999998 0.00048615727966914773
v_hist[:, 4, 4, 1]*100, v_hist[:, 4, 4, 3]*100
(array([3.3740e-05, 1.2444e-04, 1.0733e-04, 1.2617e-05, 1.1678e-05, 5.5226e-06]), array([6.8102e-05, 9.8199e-04, 1.5631e-04, 7.7221e-06, 8.5736e-06, 2.9826e-06]))
np.set_printoptions(precision=5, suppress=True)
v_hist_chevrons = v_hist.sum(axis=(0,3))
print (v_hist_chevrons.shape)
(12, 24)
print (v_hist_chevrons)
print (v_hist_chevrons[:, 6:11])
print (v_hist_chevrons[:, :6:-1])
[[0.00015 0.00642 0.00235 0.00165 0.00014 0.02706 0.00477 0.01347 0.00017 0.00777 0.00256 0.00015 0.00256 0.00777 0.00017 0.01347 0.00477 0.02706 0.00014 0.00165 0.00235 0.00642 0.00015 0.00794] [0.00013 0.00014 0.00014 0.00015 0.0061 0.00272 0.00197 0.01724 0.00674 0.0002 0.00019 0.01657 0.00019 0.0002 0.00674 0.01724 0.00197 0.00272 0.0061 0.00015 0.00014 0.00014 0.00013 0.02178] [0.00014 0.00015 0.00018 0.00015 0.00012 0.00404 0.0002 0.00475 0.00241 0.0002 0.0073 0.0081 0.0073 0.0002 0.00241 0.00475 0.0002 0.00404 0.00012 0.00015 0.00018 0.00015 0.00014 0.00019] [0.00015 0.0001 0.00017 0.00638 0.00306 0.00811 0.00084 0.00019 0.00019 0.00018 0.00017 0.00203 0.00017 0.00018 0.00019 0.00019 0.00084 0.00811 0.00306 0.00638 0.00017 0.0001 0.00015 0.00013] [0.00013 0.00014 0.00012 0.00015 0.00017 0.00017 0.00017 0.00478 0.00523 0.00018 0.00016 0.00028 0.00016 0.00018 0.00523 0.00478 0.00017 0.00018 0.00017 0.00015 0.00012 0.00014 0.00013 0.00013] [0.00015 0.00015 0.00012 0.00013 0.00013 0.00017 0.00018 0.00022 0.0002 0.0002 0.00021 0.00496 0.00021 0.0002 0.0002 0.00022 0.00018 0.00017 0.00013 0.00012 0.00012 0.00014 0.00015 0.0002 ] [0.00016 0.00013 0.00014 0.00015 0.00016 0.00013 0.00366 0.00809 0.00015 0.00017 0.00362 0.01433 0.00362 0.00017 0.00015 0.00809 0.00366 0.00013 0.00016 0.00015 0.00014 0.00014 0.00016 0.00012] [0.00021 0.00011 0.00568 0.00011 0.00017 0.00483 0.00892 0.02188 0.00997 0.00021 0.00015 0.00013 0.00015 0.00021 0.00997 0.02188 0.00892 0.00483 0.00017 0.00011 0.00568 0.00011 0.00021 0.00013] [0.00429 0.00734 0.00015 0.00015 0.0008 0.00387 0.0179 0.00012 0.00016 0.0016 0.00028 0.00545 0.00028 0.0016 0.00016 0.00012 0.0179 0.00387 0.0008 0.00015 0.00015 0.00734 0.00429 0.00011] [0.00206 0.00439 0.00012 0.00015 0.00016 0.00014 0.00075 0.00577 0.00859 0.00013 0.00015 0.00019 0.00015 0.00013 0.00859 0.00577 0.00075 0.00014 0.00016 0.00015 0.00012 0.00439 0.00206 0.00016] [0.00216 0.01514 0.0002 0.0008 0.00016 0.00359 0.01195 0.00015 0.00117 0.00018 0.00464 0.00017 0.00464 0.00018 0.00117 0.00014 0.01195 0.00359 0.00016 0.0008 0.0002 0.01514 0.00216 0.00014] [0.0172 0.03605 0.00375 0.0115 0.00868 0.00326 0.00071 0.01373 0.01798 0.00185 0.01122 0.0002 0.01122 0.00185 0.01798 0.01374 0.00071 0.00326 0.00868 0.0115 0.00375 0.03605 0.0172 0.0192 ]] [[0.00477 0.01347 0.00017 0.00777 0.00256] [0.00197 0.01724 0.00674 0.0002 0.00019] [0.0002 0.00475 0.00241 0.0002 0.0073 ] [0.00084 0.00019 0.00019 0.00018 0.00017] [0.00017 0.00478 0.00523 0.00018 0.00016] [0.00018 0.00022 0.0002 0.0002 0.00021] [0.00366 0.00809 0.00015 0.00017 0.00362] [0.00892 0.02188 0.00997 0.00021 0.00015] [0.0179 0.00012 0.00016 0.0016 0.00028] [0.00075 0.00577 0.00859 0.00013 0.00015] [0.01195 0.00015 0.00117 0.00018 0.00464] [0.00071 0.01373 0.01798 0.00185 0.01122]] [[0.00794 0.00015 0.00642 0.00235 0.00165 0.00014 0.02706 0.00477 0.01347 0.00017 0.00777 0.00256 0.00015 0.00256 0.00777 0.00017 0.01347] [0.02178 0.00013 0.00014 0.00014 0.00015 0.0061 0.00272 0.00197 0.01724 0.00674 0.0002 0.00019 0.01657 0.00019 0.0002 0.00674 0.01724] [0.00019 0.00014 0.00015 0.00018 0.00015 0.00012 0.00404 0.0002 0.00475 0.00241 0.0002 0.0073 0.0081 0.0073 0.0002 0.00241 0.00475] [0.00013 0.00015 0.0001 0.00017 0.00638 0.00306 0.00811 0.00084 0.00019 0.00019 0.00018 0.00017 0.00203 0.00017 0.00018 0.00019 0.00019] [0.00013 0.00013 0.00014 0.00012 0.00015 0.00017 0.00018 0.00017 0.00478 0.00523 0.00018 0.00016 0.00028 0.00016 0.00018 0.00523 0.00478] [0.0002 0.00015 0.00014 0.00012 0.00012 0.00013 0.00017 0.00018 0.00022 0.0002 0.0002 0.00021 0.00496 0.00021 0.0002 0.0002 0.00022] [0.00012 0.00016 0.00014 0.00014 0.00015 0.00016 0.00013 0.00366 0.00809 0.00015 0.00017 0.00362 0.01433 0.00362 0.00017 0.00015 0.00809] [0.00013 0.00021 0.00011 0.00568 0.00011 0.00017 0.00483 0.00892 0.02188 0.00997 0.00021 0.00015 0.00013 0.00015 0.00021 0.00997 0.02188] [0.00011 0.00429 0.00734 0.00015 0.00015 0.0008 0.00387 0.0179 0.00012 0.00016 0.0016 0.00028 0.00545 0.00028 0.0016 0.00016 0.00012] [0.00016 0.00206 0.00439 0.00012 0.00015 0.00016 0.00014 0.00075 0.00577 0.00859 0.00013 0.00015 0.00019 0.00015 0.00013 0.00859 0.00577] [0.00014 0.00216 0.01514 0.0002 0.0008 0.00016 0.00359 0.01195 0.00014 0.00117 0.00018 0.00464 0.00017 0.00464 0.00018 0.00117 0.00015] [0.0192 0.0172 0.03605 0.00375 0.0115 0.00868 0.00326 0.00071 0.01374 0.01798 0.00185 0.01122 0.0002 0.01122 0.00185 0.01798 0.01373]]
_ = myplot(edgeslist, mp=mp)
%load_ext watermark
%watermark
2018-07-18T11:38:05+02:00 CPython 3.7.0 IPython 6.4.0 compiler : Clang 9.1.0 (clang-902.0.39.2) system : Darwin release : 17.6.0 machine : x86_64 processor : i386 CPU cores : 4 interpreter: 64bit
%load_ext version_information
%version_information numpy, scipy, matplotlib, sympy
Software | Version |
---|---|
Python | 3.7.0 64bit [Clang 9.1.0 (clang-902.0.39.2)] |
IPython | 6.4.0 |
OS | Darwin 17.6.0 x86_64 i386 64bit |
numpy | 1.14.5 |
scipy | 1.1.0 |
matplotlib | 2.2.2 |
sympy | 1.2 |
Wed Jul 18 11:38:06 2018 CEST |
%cd -q ../notebooks