matrice.py
Go to the documentation of this file.
1 from __future__ import division
2 from object import Surface as fc
3 import numpy as np
4 import math
5 
6 
7 def create_matrix_l(faces, sigma, val):
8  # create matrix L as in Mura paper
9  riga = []
10  # create matrix with only first line
11  face = faces[0]
12  for face2 in faces:
13  adj = fc.adjacent(face, face2)
14  if face == face2:
15  val = 1
16  else:
17  if adj:
18  e = fc.common_edge(face, face2)
19  w = e[0].weight
20  val = math.exp(-w/sigma)
21  else:
22  val = 0
23  riga.append(val)
24  matrix_l = np.matrix([riga])
25  del riga[:]
26 
27  for face in faces[1:]:
28  for face2 in faces:
29  adj = fc.adjacent(face, face2)
30  if face == face2:
31  val = 1
32  else:
33  if adj:
34  e = fc.common_edge(face, face2)
35  w = e[0].weight
36  val = math.exp(-w/sigma)
37  else:
38  val = 0
39  riga.append(val)
40  matrix_l = np.vstack([matrix_l, riga])
41  del riga[:]
42  return matrix_l
43 
44 
45 def create_matrix_d(matrix_l):
46  # create matrix D as in Mura paper
47  vett = []
48  for row in matrix_l:
49  vett.append(row.sum())
50  matrix_d = np.asmatrix(np.diag(vett))
51  return matrix_d
52 
53 
54 def symmetry(M):
55  # make symmetric matrix M to put in input at dbscan
56  if type(M) == np.matrix:
57  M = np.array(M)
58  [r, c] = M.shape
59  M2 = np.copy(M)
60  for i in range(r):
61  for j in range(i, c):
62  M2[i, j] = (M[i, j] + M[j, i]) / 2
63  M2[j, i] = M2[i, j]
64  return M2
65 
matrice.symmetry
def symmetry(M)
Definition: matrice.py:54
matrice.create_matrix_d
def create_matrix_d(matrix_l)
Definition: matrice.py:45
matrice.create_matrix_l
def create_matrix_l(faces, sigma, val)
Definition: matrice.py:7


rose2
Author(s): Gabriele Somaschini, Matteo Luperto
autogenerated on Wed Jun 28 2023 02:21:53