@@ -183,7 +183,6 @@ def tempShow(text="Hello World"):
183
183
cv2 .waitKey (2500 )
184
184
cv2 .destroyWindow ("Saved" )
185
185
186
-
187
186
def InitializeASM (directory = "_Data\\ Radiographs\\ *.tif" ):
188
187
dir_radiographs = directory
189
188
radiographs = FileManager .load_files (dir_radiographs )
@@ -199,12 +198,16 @@ def InitializeASM(directory = "_Data\\Radiographs\\*.tif"):
199
198
global scale
200
199
global output
201
200
global currentImage
201
+
202
+ alpha = 1.0
203
+ distance = 10
202
204
showpopup = 1
203
205
cv2 .setMouseCallback ('Radiograph' ,moveTeeth ,(resized_image ,all_landmarks_std ))
204
206
205
207
tempShow ("Calculating Edges + PCA..." )
208
+ # global img
206
209
grays = cv2 .cvtColor (resized_image , cv2 .COLOR_BGR2GRAY )
207
- edge_img , pca_teeth = asm .preperation_all (grays , all_landmarks_std )
210
+ edge_img , pca_teeth = asm .preperation_all (grays , all_landmarks_std , scale )
208
211
tempShow ("Calculating Edges + PCA : DONE!" )
209
212
210
213
@@ -336,12 +339,12 @@ def InitializeASM(directory = "_Data\\Radiographs\\*.tif"):
336
339
elif k == 111 :
337
340
for i in range (0 ,8 ):
338
341
tooth_points = output [0 ,i ,:,:]
339
- points = asm .active_shape (edge_img , tooth_points , pca_teeth [i ], 20 , 1 )
342
+ points = asm .active_shape (edge_img , tooth_points , pca_teeth [i ], distance , alpha )
340
343
# print(all_landmarks_std[0,0,:,:])
341
344
output [0 ,i ,:,:] = points
342
345
drawTeethOutput (output , backdrop )
343
346
# print(output)
344
- tempShow ("ASM iteration complete!" )
347
+ # tempShow("ASM iteration complete!")
345
348
elif k == 47 :
346
349
# print(output)
347
350
np .save ("initial_position" , output )
@@ -352,6 +355,23 @@ def InitializeASM(directory = "_Data\\Radiographs\\*.tif"):
352
355
cv2 .imshow ("Saved" ,popup )
353
356
cv2 .waitKey (1000 )
354
357
cv2 .destroyWindow ("Saved" )
358
+ elif k == 120 :
359
+ alpha += 0.5
360
+ print ("alpha value = " + str (alpha ))
361
+ elif k == 122 :
362
+ alpha -= 0.5
363
+ print ("alpha value = " + str (alpha ))
364
+ elif k == 114 :
365
+ distance += 1
366
+ print ("pixel distance to check = " + str (distance ))
367
+ elif k == 97 :
368
+ distance -= 1
369
+ print ("pixel distance to check = " + str (distance ))
370
+ elif k == 102 :
371
+ cv2 .namedWindow ("Edge image" ,cv2 .WINDOW_AUTOSIZE )
372
+ cv2 .imshow ("Edge image" , edge_img .astype (np .uint8 )* 255 )
373
+
374
+
355
375
356
376
357
377
0 commit comments