Révision 12

bin/image2geometry/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()
bin/image2geometry/measure_sepal.py (revision 12)
48 48
#projected2Dimage_hight=outdir+"/hight_"+imnameroot+"2D.png"
49 49

  
50 50
os.system("mkdir -p "+outputdir)
51
os.system("mkdir -p "+symdir)
52 51

  
52

  
53 53
outname = outputfile.split('/')[-1]
54 54
outroot = outname.split('.')[0]
55 55

  
......
146 146
FILE = open(outputfile,"a")
147 147
FILE.write(imnameroot+';')
148 148

  
149
print("Longitudinal section:")
149 150
outfile=outroot+'_up_longitudinal.csv'
150 151
graph_name= outputdir+imnameroot+'_up_longitudinal.png'
151
length_x, flatlength_x, height_x, R, R21, R22, R41, R423, R44=analyze_curve1(imnameroot, xup, x_pixelsize, outfile, graph_name)
152

  
153
length_x, flatlength_x, height_x, R, R21, R22, R41, R423, R44=analyze_curve1(imnameroot, xup, x_pixelsize, outfile, "Longitudinal", graph_name)
152 154
os.system("rm "+outfile)
153 155

  
154 156
FILE.write(str(length_x)+';'+str(flatlength_x)+';'+str(height_x)+';'+str(R)+';'+str(R21)+';'+str(R22)+';'+str(R41)+';'+str(R423)+';'+str(R44)+';')
155 157

  
158
print("Transversal section:")
156 159
outfile=outroot+'_up_transversal.csv'
157 160
graph_name= outputdir+imnameroot+'_up_transversal.png'
158
length_y, flatlength_y, height_y, R, R21, R22, R41, R423, R44=analyze_curve1(imnameroot, yup, y_pixelsize, outfile, graph_name)
161
length_y, flatlength_y, height_y, R, R21, R22, R41, R423, R44=analyze_curve1(imnameroot, yup, y_pixelsize, outfile, "Transversal", graph_name)
159 162
os.system("rm "+outfile)
160 163

  
161 164
FILE.write(str(length_y)+';'+str(flatlength_y)+';'+str(height_y)+';'+str(R)+';'+str(R21)+';'+str(R22)+';'+str(R41)+';'+str(R423)+';'+str(R44)+';')

Formats disponibles : Unified diff