amaazetools 0.1.4__tar.gz → 0.1.5__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.
- {amaazetools-0.1.4/amaazetools.egg-info → amaazetools-0.1.5}/PKG-INFO +1 -1
- {amaazetools-0.1.4 → amaazetools-0.1.5}/amaazetools/trimesh.py +81 -0
- {amaazetools-0.1.4 → amaazetools-0.1.5/amaazetools.egg-info}/PKG-INFO +1 -1
- {amaazetools-0.1.4 → amaazetools-0.1.5}/pyproject.toml +1 -1
- {amaazetools-0.1.4 → amaazetools-0.1.5}/LICENSE +0 -0
- {amaazetools-0.1.4 → amaazetools-0.1.5}/MANIFEST.in +0 -0
- {amaazetools-0.1.4 → amaazetools-0.1.5}/README.md +0 -0
- {amaazetools-0.1.4 → amaazetools-0.1.5}/amaazetools/__init__.py +0 -0
- {amaazetools-0.1.4 → amaazetools-0.1.5}/amaazetools/dicom.py +0 -0
- {amaazetools-0.1.4 → amaazetools-0.1.5}/amaazetools/edge_detection.py +0 -0
- {amaazetools-0.1.4 → amaazetools-0.1.5}/amaazetools/mesh_segmentation.py +0 -0
- {amaazetools-0.1.4 → amaazetools-0.1.5}/amaazetools/svi.py +0 -0
- {amaazetools-0.1.4 → amaazetools-0.1.5}/amaazetools.egg-info/SOURCES.txt +0 -0
- {amaazetools-0.1.4 → amaazetools-0.1.5}/amaazetools.egg-info/dependency_links.txt +0 -0
- {amaazetools-0.1.4 → amaazetools-0.1.5}/amaazetools.egg-info/requires.txt +0 -0
- {amaazetools-0.1.4 → amaazetools-0.1.5}/amaazetools.egg-info/top_level.txt +0 -0
- {amaazetools-0.1.4 → amaazetools-0.1.5}/setup.cfg +0 -0
- {amaazetools-0.1.4 → amaazetools-0.1.5}/setup.py +0 -0
- {amaazetools-0.1.4 → amaazetools-0.1.5}/src/cextensions.c +0 -0
- {amaazetools-0.1.4 → amaazetools-0.1.5}/src/memory_allocation.c +0 -0
- {amaazetools-0.1.4 → amaazetools-0.1.5}/src/memory_allocation.h +0 -0
- {amaazetools-0.1.4 → amaazetools-0.1.5}/src/mesh_operations.c +0 -0
- {amaazetools-0.1.4 → amaazetools-0.1.5}/src/mesh_operations.h +0 -0
- {amaazetools-0.1.4 → amaazetools-0.1.5}/src/svi_computations.c +0 -0
- {amaazetools-0.1.4 → amaazetools-0.1.5}/src/svi_computations.h +0 -0
- {amaazetools-0.1.4 → amaazetools-0.1.5}/src/vector_operations.h +0 -0
|
@@ -9,6 +9,8 @@ from numpy import matlib
|
|
|
9
9
|
from plyfile import PlyData, PlyElement
|
|
10
10
|
import scipy.sparse as sparse
|
|
11
11
|
import scipy.spatial as spatial
|
|
12
|
+
import scipy.sparse.csgraph as csgraph
|
|
13
|
+
from collections import Counter
|
|
12
14
|
from skimage import measure
|
|
13
15
|
from skimage.color import convert_colorspace
|
|
14
16
|
from sklearn.neighbors import NearestNeighbors
|
|
@@ -17,6 +19,7 @@ from . import edge_detection
|
|
|
17
19
|
import sys
|
|
18
20
|
import urllib.request as url
|
|
19
21
|
|
|
22
|
+
|
|
20
23
|
#Non-Class Specific Functions
|
|
21
24
|
|
|
22
25
|
|
|
@@ -466,6 +469,84 @@ class mesh:
|
|
|
466
469
|
F = sparse.spdiags(1/num_adj_tri,0,self.num_verts(),self.num_verts())@F
|
|
467
470
|
|
|
468
471
|
return F
|
|
472
|
+
|
|
473
|
+
def detect_holes(self):
|
|
474
|
+
""" finds vertices bordering on holes.
|
|
475
|
+
|
|
476
|
+
Returns
|
|
477
|
+
-------
|
|
478
|
+
holes : (num_verts) boolean array
|
|
479
|
+
holes[i] = 1 if vertex i borders on a hole, else 0
|
|
480
|
+
"""
|
|
481
|
+
npts = self.num_verts()
|
|
482
|
+
ntri = self.num_tri()
|
|
483
|
+
|
|
484
|
+
T = self.triangles
|
|
485
|
+
#sparse matrices don't seem to be smart enough to remove 0's here in construction. I was going to add 1 and then remove it - no need
|
|
486
|
+
|
|
487
|
+
VT = self.tri_vert_adj()
|
|
488
|
+
|
|
489
|
+
ntri_per_vert = VT@np.ones(ntri) #need this later
|
|
490
|
+
max_tri = int(ntri_per_vert.max())
|
|
491
|
+
|
|
492
|
+
T1 = VT.multiply(T[:,0])
|
|
493
|
+
T2 = VT.multiply(T[:,1])
|
|
494
|
+
T3 = VT.multiply(T[:,2])
|
|
495
|
+
|
|
496
|
+
I = np.hstack((T1.row,T2.row,T3.row))
|
|
497
|
+
J = np.hstack((T1.data.astype(int), T2.data.astype(int),T3.data.astype(int)))
|
|
498
|
+
|
|
499
|
+
K = sparse.coo_matrix((np.ones(len(I)), (I,J)),shape=(npts,npts)).tocsr()
|
|
500
|
+
K.data = (K.data>0).astype(int) #the construction is additive - repeated index ~> counter
|
|
501
|
+
|
|
502
|
+
ntri_per_vert2 = (K@np.ones(npts)) -1
|
|
503
|
+
holes = ntri_per_vert2!=ntri_per_vert
|
|
504
|
+
|
|
505
|
+
return holes
|
|
506
|
+
|
|
507
|
+
|
|
508
|
+
def con_comp(self,Q=None,returncounts=False):
|
|
509
|
+
""" extracts connected components of mesh.
|
|
510
|
+
|
|
511
|
+
Parameters
|
|
512
|
+
----------
|
|
513
|
+
Q : (num_verts) boolean array , default is None
|
|
514
|
+
optional array to prune edges with. If input, only edges from True to True will be considered for connectivity.
|
|
515
|
+
If not input (or None), all edges will be used for connectivity.
|
|
516
|
+
returncounts: boolean, default is False
|
|
517
|
+
if true, will return counts for labels.
|
|
518
|
+
|
|
519
|
+
Returns
|
|
520
|
+
-------
|
|
521
|
+
ncomp : number of connected components.
|
|
522
|
+
labels : (num_verts) integer array
|
|
523
|
+
labels of connected components for each point. values range from 0 to ncomp-1.
|
|
524
|
+
counts : (ncomp) integer array
|
|
525
|
+
(optional) returns number of points under each label. array sorted from 0 to ncomp-1.
|
|
526
|
+
|
|
527
|
+
|
|
528
|
+
"""
|
|
529
|
+
T = self.triangles
|
|
530
|
+
npts = self.num_verts()
|
|
531
|
+
E = np.vstack( (T[:,[0,1]], T[:,[1,2]], T[:,[2,0]])) #edges of T
|
|
532
|
+
|
|
533
|
+
if Q is not None:
|
|
534
|
+
ll = Q[E]
|
|
535
|
+
E = E[ll[:,0]&ll[:,1],:]
|
|
536
|
+
|
|
537
|
+
E = np.vstack( (E,E[:,[1,0]]) )
|
|
538
|
+
|
|
539
|
+
W = sparse.coo_matrix((np.ones((np.shape(E)[0])), (E[:,0],E[:,1])),shape=(npts,npts))
|
|
540
|
+
|
|
541
|
+
ncomp,labels = csgraph.connected_components(W,directed=False)
|
|
542
|
+
|
|
543
|
+
if returncounts:
|
|
544
|
+
co = Counter(labels)
|
|
545
|
+
co = np.array(list(co.items()))
|
|
546
|
+
counts = co[np.argsort(co[:,0]),1]
|
|
547
|
+
return ncomp,labels,counts
|
|
548
|
+
else:
|
|
549
|
+
return ncomp,labels
|
|
469
550
|
|
|
470
551
|
#Returns unit normal vectors to vertices (averaging adjacent faces and normalizing)
|
|
471
552
|
def vertex_normals(self):
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|