Révision 12 bin/image2geometry/bib_sepals.py
bib_sepals.py (revision 12) | ||
---|---|---|
387 | 387 |
return R_2, pc |
388 | 388 |
|
389 | 389 |
|
390 |
def analyze_curve1(name, y, pixelsize, outfilename, graph_name='graph.png'): |
|
390 |
def circle(R, c): |
|
391 |
phi=np.linspace(np.pi/6., 5*np.pi/6., 51) |
|
392 |
x=c[0]+R*np.cos(phi) |
|
393 |
y=c[1]+R*np.sin(phi) |
|
394 |
return x,y |
|
395 |
|
|
396 |
|
|
397 |
|
|
398 |
def analyze_curve1(name, y, pixelsize, outfilename, title, graph_name='graph.png'): |
|
391 | 399 |
# isotropic pixels |
392 | 400 |
y[:,0] = y[:,0]*pixelsize[0] |
393 | 401 |
y[:,1] = y[:,1]*pixelsize[1] |
... | ... | |
418 | 426 |
middle_point = yy[int(len(yy)/2)] |
419 | 427 |
# compute curvature radius by fitting the sepal section to a circle |
420 | 428 |
yyy=y[first:last] |
421 |
R, pc = compute_curvature_radius(yyy[:,0],yyy[:,1]) |
|
429 |
R, pcR = compute_curvature_radius(yyy[:,0],yyy[:,1])
|
|
422 | 430 |
print("R=",R," um") |
423 | 431 |
# cutting curve in pieces in order to estimate curvature radius on portions of the curve |
424 | 432 |
slength=len(yyy) |
... | ... | |
428 | 436 |
y423=yyy[int(slength/4):3*int(slength/4)] |
429 | 437 |
y44=yyy[3*int(slength/4):slength] |
430 | 438 |
# and computing the curvature radius for each portion |
431 |
R21, pc = compute_curvature_radius(y21[:,0],y21[:,1]) |
|
432 |
R22, pc = compute_curvature_radius(y22[:,0],y22[:,1]) |
|
433 |
R41, pc = compute_curvature_radius(y41[:,0],y41[:,1]) |
|
434 |
R423, pc = compute_curvature_radius(y423[:,0],y423[:,1]) |
|
435 |
R44, pc = compute_curvature_radius(y44[:,0],y44[:,1]) |
|
436 |
fig = plt.figure() |
|
437 |
plt.plot(yy[:,0], yy[:,1], 'bo') |
|
438 |
plt.plot(y[:,0], y[:,1], 'r') |
|
439 |
plt.plot(y[first][0], y[first][1], 'ro') |
|
440 |
plt.plot(middle_point[0], middle_point[1], 'ro') |
|
441 |
plt.plot(y[last][0], y[last][1], 'ro') |
|
442 |
plt.plot(yy[height_index][0], yy[height_index][1], 'go') |
|
443 |
plt.plot(pc[0], pc[1], 'bx') |
|
439 |
R21, pc21 = compute_curvature_radius(y21[:,0],y21[:,1]) |
|
440 |
R22, pc22 = compute_curvature_radius(y22[:,0],y22[:,1]) |
|
441 |
R41, pc41 = compute_curvature_radius(y41[:,0],y41[:,1]) |
|
442 |
R423, pc423 = compute_curvature_radius(y423[:,0],y423[:,1]) |
|
443 |
R44, pc44 = compute_curvature_radius(y44[:,0],y44[:,1]) |
|
444 |
fig = plt.figure(figsize=(15, 5)) |
|
445 |
plt.plot(yy[:,0], yy[:,1], color='lightgreen', linewidth=10, label='length='+"{:.0f}".format(length)+" um") |
|
446 |
#plt.plot(y[:,0], y[:,1], '--') |
|
447 |
#plt.plot(y[first][0], y[first][1], 'ro') |
|
448 |
#plt.plot(middle_point[0], middle_point[1], 'ro') |
|
449 |
#plt.plot(y[last][0], y[last][1], 'ro') |
|
450 |
#plt.plot(yy[height_index][0], yy[height_index][1], 'go') |
|
451 |
#plt.plot(pcR[0], pcR[1], 'ro', color='royalblue') |
|
452 |
#plt.plot(pc423[0], pc423[1], 'ro', color='darkorange') |
|
453 |
xR,yR = circle(R, pcR) |
|
454 |
plt.plot(xR, yR, "--",color='royalblue', linewidth=3, label='R='+"{:.0f}".format(R)+" um") |
|
455 |
xR,yR = circle(R423, pc423) |
|
456 |
plt.plot(xR, yR, "--", color='tomato', linewidth=3, label='R423='+"{:.0f}".format(R423)+" um") |
|
444 | 457 |
plt.gca().set_aspect('equal', adjustable='box') |
458 |
plt.xlabel('x (um)') |
|
459 |
plt.ylabel('z (um)') |
|
460 |
plt.legend() |
|
461 |
plt.grid(True) |
|
462 |
plt.title(title) |
|
445 | 463 |
#plt.show() |
446 | 464 |
fig.savefig(graph_name) |
447 | 465 |
#plt.close() |
Formats disponibles : Unified diff