imicpe 1.0.4__py3-none-any.whl → 1.0.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
imicpe/_version.py CHANGED
@@ -1 +1 @@
1
- __version__="1.0.4"
1
+ __version__="1.0.6"
imicpe/optim/__init__.py CHANGED
@@ -1,5 +1,5 @@
1
1
  from .metrics import mse, snr
2
- from .operators import Id, D, Dt, L, Lt, generatePSF, A, At, S, St, opNorm, matNorm
2
+ from .operators import Id, D, Dt, L, Lt, generateDiff3D, generatePSF, A, At, S, St, opNorm, matNorm
3
3
  from .pnnDataset import BSDSDataset, NoisyDataset
4
4
  from .pnnTrainer import Trainer, Metrics
5
5
  from .pnnUtils import chooseDevice, torchImg2Numpy, getData
imicpe/optim/operators.py CHANGED
@@ -1,6 +1,7 @@
1
1
  import numpy as np
2
2
  from scipy import ndimage
3
3
  #import igl
4
+ import scipy.sparse as sp
4
5
 
5
6
  ############################################################
6
7
  ## identity operator
@@ -128,9 +129,63 @@ def generateDiff3D(vert, faces, dtype):
128
129
  """
129
130
 
130
131
  if dtype == 'gradient':
131
- matG = igl.grad(vert, faces)
132
+ #matG = igl.grad(vert, faces)
133
+ n = vert.shape[0]
134
+ G = sp.lil_matrix((3 * len(faces), n))
135
+ for f_idx, tri in enumerate(faces):
136
+ i, j, k = tri
137
+ vi, vj, vk = vert[i], vert[j], vert[k]
138
+ # Normale du triangle
139
+ normal = np.cross(vj - vi, vk - vi)
140
+ area = np.linalg.norm(normal) / 2.0
141
+ normal /= np.linalg.norm(normal) if np.linalg.norm(normal) > 0 else 1
142
+ # Gradients barycentriques
143
+ G_f = np.zeros((3, 3))
144
+ G_f[:, 0] = np.cross(normal, vk - vj) / (2 * area)
145
+ G_f[:, 1] = np.cross(normal, vi - vk) / (2 * area)
146
+ G_f[:, 2] = np.cross(normal, vj - vi) / (2 * area)
147
+ # Assignation dans la matrice globale
148
+ for local_idx, global_idx in enumerate(tri):
149
+ G[3 * f_idx: 3 * f_idx + 3, global_idx] = G_f[:, local_idx]
150
+
151
+ matG = G.tocsc()
152
+
132
153
  elif dtype == 'laplacien':
133
- matG = igl.cotmatrix(vert, faces)
154
+ #matG = igl.cotmatrix(vert, faces)
155
+ n = vert.shape[0]
156
+ L = sp.lil_matrix((n, n))
157
+
158
+ for tri in faces:
159
+ i, j, k = tri
160
+ vi, vj, vk = vert[i], vert[j], vert[k]
161
+
162
+ # Calcul des arêtes
163
+ e0 = vj - vk
164
+ e1 = vk - vi
165
+ e2 = vi - vj
166
+
167
+ # Longueurs des arêtes
168
+ l0 = np.linalg.norm(e0)
169
+ l1 = np.linalg.norm(e1)
170
+ l2 = np.linalg.norm(e2)
171
+
172
+ # Calcul des angles via le produit scalaire
173
+ cot0 = np.dot(-e1, e2) / (l1 * l2)
174
+ cot1 = np.dot(-e2, e0) / (l2 * l0)
175
+ cot2 = np.dot(-e0, e1) / (l0 * l1)
176
+
177
+ # Construction de la matrice du Laplacien
178
+ L[i, j] += cot2
179
+ L[j, i] += cot2
180
+ L[j, k] += cot0
181
+ L[k, j] += cot0
182
+ L[k, i] += cot1
183
+ L[i, k] += cot1
184
+ L[i, i] -= (cot1 + cot2)
185
+ L[j, j] -= (cot0 + cot2)
186
+ L[k, k] -= (cot0 + cot1)
187
+
188
+ matG = L.tocsc()
134
189
 
135
190
  return (matG/np.amax(matG)).toarray()
136
191
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: imicpe
3
- Version: 1.0.4
3
+ Version: 1.0.6
4
4
  Summary: Toolbox for Maths,Signal,Image Teaching @ CPE
5
5
  Author-email: Marion Foare <marion.foare@cpe.fr>, Eric Van Reeth <eric.vanreeth@cpe.fr>, Arthur Gautheron <arthur.gautheron@cpe.fr>
6
6
  License: MIT License
@@ -1,5 +1,5 @@
1
1
  imicpe/__init__.py,sha256=WjDmvecyDIyJLYp4rCV9vsSYbQDc4L1EpYqORvEXliI,33
2
- imicpe/_version.py,sha256=_Mzv05Nk6f7wR8F5KqE69kN9PfdC4uxj5YvG98nbUcs,20
2
+ imicpe/_version.py,sha256=pINtsbN0HBnfwDigU9BkYOfkTQAdnUydSLeEcyBcXBs,20
3
3
  imicpe/cs/__init__.py,sha256=fLe1o5jNvrB4qEVBE6amEV9i3NFwM3E_uGiiiHXrph0,339
4
4
  imicpe/cs/l1.py,sha256=5bTNM8JG8J8srTamh-gl3ShhFoJjqCvVwlteN_M6Uak,3236
5
5
  imicpe/cs/masks.py,sha256=5ehQ-QnYY4trBt7BIx0Pp8DUa3x5KApkc7TPp9LA9Pc,2030
@@ -7,14 +7,14 @@ imicpe/cs/metrics.py,sha256=DuUYpW7s1LkZTDV32D5K4wdSRXpH1Ymunjp2vq6kzfA,148
7
7
  imicpe/cs/operators.py,sha256=pTA8gu_17yoBD4Hs7Cvg0PWUX4xrcMr6DJxyNYX9yBA,9028
8
8
  imicpe/cs/shepp_logan_phantom.py,sha256=_RDHimZI6R8uyAwXNyB3BldYjCiNDRorDmPYoJR0T6Q,485
9
9
  imicpe/cs/tikhonov.py,sha256=NokBVdMsErWrf4pHZ3jWFwyRVaP7Z9z4qqujuisjyF4,2488
10
- imicpe/optim/__init__.py,sha256=rkguPFq7gdmBgm_Xrry2yr1oquEIxE00On2emjRMgZE,344
10
+ imicpe/optim/__init__.py,sha256=m3A1xTbMnHMqOx8EFWi71BRyVmlCdVL4qtNYWct0rjQ,360
11
11
  imicpe/optim/metrics.py,sha256=lcXT5gLtIdGARr5Lq1fWvVQNyqkKgy8BQsV4cHmbnvM,187
12
- imicpe/optim/operators.py,sha256=qEvFqgmg5uDkdd0MU2bAxIq8Erg6BZsdtnHn0SwXASY,10642
12
+ imicpe/optim/operators.py,sha256=eSiY9X6ZI3dWsMjkWkR3rsi06yfpNHpHFWTVPaNqeWg,12589
13
13
  imicpe/optim/pnnDataset.py,sha256=PFh5u0SXx761O6N6vVfWfEDmzmCm87eYzAL7mWHBRrw,3971
14
14
  imicpe/optim/pnnTrainer.py,sha256=3ygh9XwFJN7jMPsEG3LHLa8sgBbDd9Yu_QWg4ZtM_DM,4571
15
15
  imicpe/optim/pnnUtils.py,sha256=LXU7wRfuEi6t-2VG2NStPAOzu19OKTxzNNnbHESpC2U,1523
16
- imicpe-1.0.4.dist-info/licenses/LICENSE,sha256=ACwmltkrXIz5VsEQcrqljq-fat6ZXAMepjXGoe40KtE,1069
17
- imicpe-1.0.4.dist-info/METADATA,sha256=R49h9z7HFp_ZVQF8HiVz68IaHysJFi0eXP-26oOk4Vk,1339
18
- imicpe-1.0.4.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
19
- imicpe-1.0.4.dist-info/top_level.txt,sha256=6_gSXCYolzjXHaIDeAsZ_M3nLXdqrMKt48XCz3reJc0,7
20
- imicpe-1.0.4.dist-info/RECORD,,
16
+ imicpe-1.0.6.dist-info/licenses/LICENSE,sha256=ACwmltkrXIz5VsEQcrqljq-fat6ZXAMepjXGoe40KtE,1069
17
+ imicpe-1.0.6.dist-info/METADATA,sha256=WT7c8C1l6Z0k34bK5Pcm6gjJ5m4MQG2-sIfKSxXcN5M,1339
18
+ imicpe-1.0.6.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
19
+ imicpe-1.0.6.dist-info/top_level.txt,sha256=6_gSXCYolzjXHaIDeAsZ_M3nLXdqrMKt48XCz3reJc0,7
20
+ imicpe-1.0.6.dist-info/RECORD,,
File without changes