amaazetools 0.1.3__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.3/amaazetools.egg-info → amaazetools-0.1.5}/PKG-INFO +2 -2
- {amaazetools-0.1.3 → amaazetools-0.1.5}/README.md +1 -1
- {amaazetools-0.1.3 → amaazetools-0.1.5}/amaazetools/trimesh.py +110 -45
- {amaazetools-0.1.3 → amaazetools-0.1.5/amaazetools.egg-info}/PKG-INFO +2 -2
- {amaazetools-0.1.3 → amaazetools-0.1.5}/pyproject.toml +1 -1
- {amaazetools-0.1.3 → amaazetools-0.1.5}/src/cextensions.c +2 -0
- {amaazetools-0.1.3 → amaazetools-0.1.5}/LICENSE +0 -0
- {amaazetools-0.1.3 → amaazetools-0.1.5}/MANIFEST.in +0 -0
- {amaazetools-0.1.3 → amaazetools-0.1.5}/amaazetools/__init__.py +0 -0
- {amaazetools-0.1.3 → amaazetools-0.1.5}/amaazetools/dicom.py +0 -0
- {amaazetools-0.1.3 → amaazetools-0.1.5}/amaazetools/edge_detection.py +0 -0
- {amaazetools-0.1.3 → amaazetools-0.1.5}/amaazetools/mesh_segmentation.py +0 -0
- {amaazetools-0.1.3 → amaazetools-0.1.5}/amaazetools/svi.py +0 -0
- {amaazetools-0.1.3 → amaazetools-0.1.5}/amaazetools.egg-info/SOURCES.txt +0 -0
- {amaazetools-0.1.3 → amaazetools-0.1.5}/amaazetools.egg-info/dependency_links.txt +0 -0
- {amaazetools-0.1.3 → amaazetools-0.1.5}/amaazetools.egg-info/requires.txt +0 -0
- {amaazetools-0.1.3 → amaazetools-0.1.5}/amaazetools.egg-info/top_level.txt +0 -0
- {amaazetools-0.1.3 → amaazetools-0.1.5}/setup.cfg +0 -0
- {amaazetools-0.1.3 → amaazetools-0.1.5}/setup.py +0 -0
- {amaazetools-0.1.3 → amaazetools-0.1.5}/src/memory_allocation.c +0 -0
- {amaazetools-0.1.3 → amaazetools-0.1.5}/src/memory_allocation.h +0 -0
- {amaazetools-0.1.3 → amaazetools-0.1.5}/src/mesh_operations.c +0 -0
- {amaazetools-0.1.3 → amaazetools-0.1.5}/src/mesh_operations.h +0 -0
- {amaazetools-0.1.3 → amaazetools-0.1.5}/src/svi_computations.c +0 -0
- {amaazetools-0.1.3 → amaazetools-0.1.5}/src/svi_computations.h +0 -0
- {amaazetools-0.1.3 → amaazetools-0.1.5}/src/vector_operations.h +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: amaazetools
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.5
|
|
4
4
|
Summary: Python package for mesh processing tools developed by AMAAZE
|
|
5
5
|
Author-email: Jeff Calder <jwcalder@umn.edu>
|
|
6
6
|
License: MIT
|
|
@@ -50,7 +50,7 @@ Email <jwcalder@umn.edu> with any questions or comments.
|
|
|
50
50
|
|
|
51
51
|
## Contributors
|
|
52
52
|
|
|
53
|
-
Several people have contributed to the development of this software:
|
|
53
|
+
Several people have contributed to the development of this software:
|
|
54
54
|
|
|
55
55
|
1. David Floeder
|
|
56
56
|
2. Riley O'Neill
|
|
@@ -26,7 +26,7 @@ Email <jwcalder@umn.edu> with any questions or comments.
|
|
|
26
26
|
|
|
27
27
|
## Contributors
|
|
28
28
|
|
|
29
|
-
Several people have contributed to the development of this software:
|
|
29
|
+
Several people have contributed to the development of this software:
|
|
30
30
|
|
|
31
31
|
1. David Floeder
|
|
32
32
|
2. Riley O'Neill
|
|
@@ -9,13 +9,17 @@ 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
|
|
15
|
+
from skimage.color import convert_colorspace
|
|
13
16
|
from sklearn.neighbors import NearestNeighbors
|
|
14
17
|
from . import svi
|
|
15
18
|
from . import edge_detection
|
|
16
19
|
import sys
|
|
17
20
|
import urllib.request as url
|
|
18
21
|
|
|
22
|
+
|
|
19
23
|
#Non-Class Specific Functions
|
|
20
24
|
|
|
21
25
|
|
|
@@ -465,6 +469,84 @@ class mesh:
|
|
|
465
469
|
F = sparse.spdiags(1/num_adj_tri,0,self.num_verts(),self.num_verts())@F
|
|
466
470
|
|
|
467
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
|
|
468
550
|
|
|
469
551
|
#Returns unit normal vectors to vertices (averaging adjacent faces and normalizing)
|
|
470
552
|
def vertex_normals(self):
|
|
@@ -653,13 +735,18 @@ class mesh:
|
|
|
653
735
|
return mesh
|
|
654
736
|
|
|
655
737
|
#Write a ply file
|
|
656
|
-
def to_ply(self,fname):
|
|
738
|
+
def to_ply(self,fname,c=None):
|
|
657
739
|
""" Writes the mesh to a .ply file.
|
|
658
740
|
|
|
659
741
|
Parameters
|
|
660
742
|
----------
|
|
661
743
|
fname : str
|
|
662
744
|
The name of the .ply file to write the mesh to.
|
|
745
|
+
c : numpy array
|
|
746
|
+
Color array. If provided, then color is added to ply file.
|
|
747
|
+
If array is num_vert x 3, it is interprted as RGB colors
|
|
748
|
+
in the range 0,...,255. If the array is one dimensional
|
|
749
|
+
of length num_vert, then the values are interpreted as hues.
|
|
663
750
|
"""
|
|
664
751
|
|
|
665
752
|
f = open(fname,"w")
|
|
@@ -671,6 +758,11 @@ class mesh:
|
|
|
671
758
|
f.write('property double x\n')
|
|
672
759
|
f.write('property double y\n')
|
|
673
760
|
f.write('property double z\n')
|
|
761
|
+
#Write color header if colors are provided
|
|
762
|
+
if c is not None:
|
|
763
|
+
f.write('property uchar red\n')
|
|
764
|
+
f.write('property uchar green\n')
|
|
765
|
+
f.write('property uchar blue\n')
|
|
674
766
|
f.write('element face %u\n'%self.num_tri())
|
|
675
767
|
f.write('property list int int vertex_indices\n')
|
|
676
768
|
f.write('end_header\n')
|
|
@@ -678,8 +770,23 @@ class mesh:
|
|
|
678
770
|
|
|
679
771
|
f = open(fname,"ab")
|
|
680
772
|
|
|
681
|
-
#
|
|
682
|
-
|
|
773
|
+
#If no colors are provided
|
|
774
|
+
if c is None:
|
|
775
|
+
#write vertices
|
|
776
|
+
f.write(self.points.astype('float64').tobytes())
|
|
777
|
+
#If colors are provided
|
|
778
|
+
else:
|
|
779
|
+
#If scalars provided, then convert from hue to rgb
|
|
780
|
+
if c.ndim == 1:
|
|
781
|
+
c = c - np.min(c)
|
|
782
|
+
c = c/np.max(c)
|
|
783
|
+
arr = np.vstack((c,np.ones_like(c),np.ones_like(c))).T
|
|
784
|
+
c = 255*convert_colorspace(arr,'HSV','RGB')
|
|
785
|
+
|
|
786
|
+
#write vertices
|
|
787
|
+
for i in range(self.num_verts()):
|
|
788
|
+
f.write(self.points[i,:].astype('float64').tobytes())
|
|
789
|
+
f.write(c[i,:].astype('uint8').tobytes())
|
|
683
790
|
|
|
684
791
|
#write faces
|
|
685
792
|
T = np.hstack((np.ones((self.num_tri(),1))*3,self.triangles)).astype(int)
|
|
@@ -688,48 +795,6 @@ class mesh:
|
|
|
688
795
|
#close file
|
|
689
796
|
f.close()
|
|
690
797
|
|
|
691
|
-
#Write a ply file
|
|
692
|
-
def write_color_ply(self,color,fname):
|
|
693
|
-
""" Writes the colored mesh to a .ply file.
|
|
694
|
-
|
|
695
|
-
Parameters
|
|
696
|
-
----------
|
|
697
|
-
color : (num,verts,3) float array
|
|
698
|
-
An array of color data for each point.
|
|
699
|
-
fname : str
|
|
700
|
-
The name of the .ply file to write the colored mesh to.
|
|
701
|
-
"""
|
|
702
|
-
|
|
703
|
-
f = open(fname,"w")
|
|
704
|
-
|
|
705
|
-
#Write header
|
|
706
|
-
f.write('ply\n')
|
|
707
|
-
f.write('format binary_little_endian 1.0\n')
|
|
708
|
-
f.write('element vertex %u\n'%self.num_verts())
|
|
709
|
-
f.write('property double x\n')
|
|
710
|
-
f.write('property double y\n')
|
|
711
|
-
f.write('property double z\n')
|
|
712
|
-
f.write('property uchar red\n')
|
|
713
|
-
f.write('property uchar green\n')
|
|
714
|
-
f.write('property uchar blue\n')
|
|
715
|
-
f.write('element face %u\n'%self.num_tri())
|
|
716
|
-
f.write('property list int int vertex_indices\n')
|
|
717
|
-
f.write('end_header\n')
|
|
718
|
-
f.close()
|
|
719
|
-
|
|
720
|
-
f = open(fname,"ab")
|
|
721
|
-
|
|
722
|
-
#write vertices
|
|
723
|
-
for i in range(self.num_verts()):
|
|
724
|
-
f.write(P[i,:].astype('float64').tobytes())
|
|
725
|
-
f.write(color[i,:].astype('uint8').tobytes())
|
|
726
|
-
|
|
727
|
-
#write faces
|
|
728
|
-
T = np.hstack((np.ones((self.num_tri(),1))*3,T)).astype(int)
|
|
729
|
-
f.write(T.astype('int32').tobytes())
|
|
730
|
-
|
|
731
|
-
#close file
|
|
732
|
-
f.close()
|
|
733
798
|
|
|
734
799
|
def to_gif(self,fname,color = [],duration=7,fps=20,size=750,histeq = True):
|
|
735
800
|
""" Writes rotating gif
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: amaazetools
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.5
|
|
4
4
|
Summary: Python package for mesh processing tools developed by AMAAZE
|
|
5
5
|
Author-email: Jeff Calder <jwcalder@umn.edu>
|
|
6
6
|
License: MIT
|
|
@@ -50,7 +50,7 @@ Email <jwcalder@umn.edu> with any questions or comments.
|
|
|
50
50
|
|
|
51
51
|
## Contributors
|
|
52
52
|
|
|
53
|
-
Several people have contributed to the development of this software:
|
|
53
|
+
Several people have contributed to the development of this software:
|
|
54
54
|
|
|
55
55
|
1. David Floeder
|
|
56
56
|
2. Riley O'Neill
|
|
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
|