1
1
2
2
# coding: utf-8
3
3
4
- # In[5 ]:
4
+ # In[46 ]:
5
5
6
6
7
7
import MatchingModelPoints as match
12
12
import Image_preperation as prep
13
13
import PCA_analysis as PCA
14
14
import ActiveFitContour as af
15
+ import time
15
16
16
17
def active_shape_scale_n_times (img , tooth_points , pca_tooth , length , scale , n_times ):
17
18
@@ -37,14 +38,22 @@ def active_shape_scale(img, tooth_points, pca_tooth, length, scale):
37
38
38
39
return new_scaled_points
39
40
40
- def active_shape (edge_img , tooth_points , pca_tooth , length , alfa ):
41
+ def active_shape (edge_img , tooth_points , pca_tooth , length , alfa , activeFitON , MatchingON = True ):
41
42
42
- new_points , error = fit .fit_measure (tooth_points , length , edge_img )
43
- # new_points = af.active_contour(tooth_points, edge_img, length, alfa)
44
- b , pose_param = match .match_model_points (new_points , pca_tooth )
43
+ if (activeFitON ):
44
+ new_points = af .active_contour (tooth_points , edge_img , length , alfa )
45
+ else :
46
+ new_points , error = fit .fit_measure (tooth_points , length , edge_img )
47
+
48
+ if (MatchingON ):
49
+ b , pose_param = match .match_model_points (new_points , pca_tooth )
50
+ x = match .generate_model_point (b , pca_tooth )
51
+ y = match .inv_transform (x .reshape (40 ,2 ),pose_param )
52
+ else :
53
+ y = new_points
54
+
55
+ return y
45
56
46
- x = match .generate_model_point (b , pca_tooth )
47
- return match .inv_transform (x .reshape (40 ,2 ),pose_param )
48
57
49
58
def active_shape_n_times (edge_img , tooth_points , pca_tooth , length ,alfa , n_times ):
50
59
@@ -116,6 +125,13 @@ def testings():
116
125
points_array = active_shape_n_times (edge_img , tooth , pca_tooth , 10 , 20 ,9 )
117
126
118
127
show_evolution (img , points_array )
128
+
129
+
130
+ def show_with_points (img , points ):
131
+ fig , ax = plt .subplots (figsize = (15 , 15 ))
132
+ plt .imshow (img )
133
+ plt .plot (points [:,0 ], points [:,1 ], 'ro' , markersize = 1 )
134
+ plt .show ()
119
135
120
136
121
137
# In[2]:
@@ -140,5 +156,9 @@ def testings():
140
156
plt .plot (tooth [:,0 ], tooth [:,1 ], 'ro' , markersize = 1 )
141
157
plt .show ()
142
158
143
- points = active_shape_n_times (edge_img , tooth , pca_tooth , 10 , 1 ,1 )
159
+ points_list = active_shape_n_times (edge_img , tooth , pca_tooth , 10 , 1 ,1 )
160
+
161
+ #show_evolution(radiograph,points_list)
162
+ for points in points_list :
163
+ show_with_points (radiograph , points )
144
164
0 commit comments