Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9a9ab79

Browse files
committed
Use fitting only
added buttons to change alpha, length in interface
1 parent 3d41fbf commit 9a9ab79

File tree

3 files changed

+30
-10
lines changed

3 files changed

+30
-10
lines changed

‎ActiveShapeModel.py‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ def active_shape_scale(img, tooth_points, pca_tooth, length, scale):
3939

4040
def active_shape(edge_img, tooth_points, pca_tooth, length, alfa):
4141

42-
#new_points, error = fit.fit_measure(tooth_points, length, edge_img)
43-
new_points = af.active_contour(tooth_points, edge_img, length, alfa)
42+
new_points, error = fit.fit_measure(tooth_points, length, edge_img)
43+
# new_points = af.active_contour(tooth_points, edge_img, length, alfa)
4444
b, pose_param = match.match_model_points(new_points, pca_tooth)
4545

4646
x = match.generate_model_point(b, pca_tooth)
@@ -57,12 +57,11 @@ def active_shape_n_times(edge_img, tooth_points, pca_tooth, length,alfa, n_times
5757
return points
5858

5959

60-
def preperation_all(radiograph, all_landmarks):
60+
def preperation_all(radiograph, all_landmarks,scale):
6161

6262
#median = prep.median_filter(radiograph)
6363
# edge_img = prep.edge_detection_low(median)
64-
65-
edge_img = prep.calc_external_img_active_contour(radiograph)
64+
edge_img = prep.calc_external_img_active_contour(radiograph,scale)
6665
pcas_tooth = PCA.PCA_analysis_all(all_landmarks, None)
6766

6867
return edge_img, pcas_tooth

‎FitFunction.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ def show_results_fitting():
249249
piece = fm.load_img_piece()
250250
edge_img = prep.canny(piece)
251251
tooth = fm.load_tooth_of_piece(0)
252-
new_points_list, total_error = fit_measure(tooth, 30, edge_img)
252+
new_points_list, total_error = fit_measure(tooth, 25, edge_img)
253253
for i in range(7):
254254
tooth = fm.load_tooth_of_piece(i+1)
255255
new_points, total_error = fit_measure(tooth, 25, edge_img)
@@ -311,6 +311,7 @@ def show_results_fitting():
311311

312312
p = strongest_edge_point_on_normal(a,b,c,20, edge_img)
313313
show_with_points(edge_img,np.append(visualize_points,p).reshape(-1,2))
314+
show_results_fitting()
314315

315316
# piece = prep.median_filter(piece)
316317
# edge_img = prep.edge_detection_high(piece)

‎Initialisation.py‎

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ def tempShow(text="Hello World"):
183183
cv2.waitKey(2500)
184184
cv2.destroyWindow("Saved")
185185

186-
187186
def InitializeASM(directory = "_Data\\Radiographs\\*.tif"):
188187
dir_radiographs = directory
189188
radiographs = FileManager.load_files(dir_radiographs)
@@ -199,12 +198,16 @@ def InitializeASM(directory = "_Data\\Radiographs\\*.tif"):
199198
global scale
200199
global output
201200
global currentImage
201+
202+
alpha = 1.0
203+
distance = 10
202204
showpopup=1
203205
cv2.setMouseCallback('Radiograph',moveTeeth,(resized_image,all_landmarks_std))
204206

205207
tempShow("Calculating Edges + PCA...")
208+
# global img
206209
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)
208211
tempShow("Calculating Edges + PCA : DONE!")
209212

210213

@@ -336,12 +339,12 @@ def InitializeASM(directory = "_Data\\Radiographs\\*.tif"):
336339
elif k == 111:
337340
for i in range(0,8):
338341
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)
340343
# print(all_landmarks_std[0,0,:,:])
341344
output[0,i,:,:] = points
342345
drawTeethOutput(output, backdrop)
343346
# print(output)
344-
tempShow("ASM iteration complete!")
347+
# tempShow("ASM iteration complete!")
345348
elif k == 47:
346349
# print(output)
347350
np.save("initial_position", output)
@@ -352,6 +355,23 @@ def InitializeASM(directory = "_Data\\Radiographs\\*.tif"):
352355
cv2.imshow("Saved",popup)
353356
cv2.waitKey(1000)
354357
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+
355375

356376

357377

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /