def estimate_skew_angle(image, angles, debug):
estimates = []
for a in angles:
v = np.mean(interpolation.rotate(image, a, order=0, mode='constant'),
axis=1)
v = np.var(v)
estimates.append((v,a))
if debug>0:
plt.clf()
plt.title("estimate_skew_angle")
plt.plot([y for x,y in estimates],[x for x,y in estimates])
raw_input("PRESS ANY KEY TO CONTINUE.")
_, a = max(estimates)
return a
评论列表
文章目录