imicpe 1.0.5__tar.gz → 1.0.7__tar.gz

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.
Files changed (27) hide show
  1. {imicpe-1.0.5 → imicpe-1.0.7}/PKG-INFO +1 -1
  2. {imicpe-1.0.5 → imicpe-1.0.7}/pyproject.toml +1 -1
  3. imicpe-1.0.7/src/imicpe/_version.py +1 -0
  4. {imicpe-1.0.5 → imicpe-1.0.7}/src/imicpe/optim/operators.py +58 -3
  5. {imicpe-1.0.5 → imicpe-1.0.7}/src/imicpe/optim/pnnUtils.py +4 -1
  6. {imicpe-1.0.5 → imicpe-1.0.7}/src/imicpe.egg-info/PKG-INFO +1 -1
  7. imicpe-1.0.5/src/imicpe/_version.py +0 -1
  8. {imicpe-1.0.5 → imicpe-1.0.7}/DESCRIPTION.md +0 -0
  9. {imicpe-1.0.5 → imicpe-1.0.7}/LICENSE +0 -0
  10. {imicpe-1.0.5 → imicpe-1.0.7}/README.md +0 -0
  11. {imicpe-1.0.5 → imicpe-1.0.7}/setup.cfg +0 -0
  12. {imicpe-1.0.5 → imicpe-1.0.7}/src/imicpe/__init__.py +0 -0
  13. {imicpe-1.0.5 → imicpe-1.0.7}/src/imicpe/cs/__init__.py +0 -0
  14. {imicpe-1.0.5 → imicpe-1.0.7}/src/imicpe/cs/l1.py +0 -0
  15. {imicpe-1.0.5 → imicpe-1.0.7}/src/imicpe/cs/masks.py +0 -0
  16. {imicpe-1.0.5 → imicpe-1.0.7}/src/imicpe/cs/metrics.py +0 -0
  17. {imicpe-1.0.5 → imicpe-1.0.7}/src/imicpe/cs/operators.py +0 -0
  18. {imicpe-1.0.5 → imicpe-1.0.7}/src/imicpe/cs/shepp_logan_phantom.py +0 -0
  19. {imicpe-1.0.5 → imicpe-1.0.7}/src/imicpe/cs/tikhonov.py +0 -0
  20. {imicpe-1.0.5 → imicpe-1.0.7}/src/imicpe/optim/__init__.py +0 -0
  21. {imicpe-1.0.5 → imicpe-1.0.7}/src/imicpe/optim/metrics.py +0 -0
  22. {imicpe-1.0.5 → imicpe-1.0.7}/src/imicpe/optim/pnnDataset.py +0 -0
  23. {imicpe-1.0.5 → imicpe-1.0.7}/src/imicpe/optim/pnnTrainer.py +0 -0
  24. {imicpe-1.0.5 → imicpe-1.0.7}/src/imicpe.egg-info/SOURCES.txt +0 -0
  25. {imicpe-1.0.5 → imicpe-1.0.7}/src/imicpe.egg-info/dependency_links.txt +0 -0
  26. {imicpe-1.0.5 → imicpe-1.0.7}/src/imicpe.egg-info/requires.txt +0 -0
  27. {imicpe-1.0.5 → imicpe-1.0.7}/src/imicpe.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: imicpe
3
- Version: 1.0.5
3
+ Version: 1.0.7
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
@@ -14,7 +14,7 @@ mypkg = ["*.txt", "*.mat", "*.npy"]
14
14
  #[tool.setuptools_scm]
15
15
 
16
16
  [project]
17
- version="1.0.5"
17
+ version="1.0.7"
18
18
  name = "imicpe"
19
19
  authors = [
20
20
  { name="Marion Foare", email="marion.foare@cpe.fr" },
@@ -0,0 +1 @@
1
+ __version__="1.0.7"
@@ -1,6 +1,7 @@
1
1
  import numpy as np
2
2
  from scipy import ndimage
3
- import igl
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
 
@@ -38,7 +38,10 @@ def torchImg2Numpy(image):
38
38
  if image.shape[-1] == 1:
39
39
  image = image[..., 0]
40
40
 
41
- return image.numpy()
41
+ np_img = image.numpy()
42
+
43
+ return (np_img-np.min(np_img)) / (np.max(np_img)-np.min(np_img))
44
+
42
45
 
43
46
 
44
47
  def getData(trainer, mode):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: imicpe
3
- Version: 1.0.5
3
+ Version: 1.0.7
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 +0,0 @@
1
- __version__="1.0.5"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes