def test(test_func):
lena = imread('lena512.png')
n = 100
error_all = np.zeros([n])
pbar = progressbar.ProgressBar(max_value=n)
for i in range(n):
pbar.update(i+1)
x_true = np.random.random()*6-5
y_true = np.random.random()*6-5
# ex) left:5, up:30 => translation=(5, 30)
t_form = tf.SimilarityTransform(translation=(x_true, y_true))
lena_shift = tf.warp(lena, t_form)
a1 = np.random.randint(10, 50)
a2 = np.random.randint(10, 50)
a3 = np.random.randint(10, 50)
a4 = np.random.randint(10, 50)
img1 = lena[a1:-a2, a3:-a4]
img2 = lena_shift[a1:-a2, a3:-a4]
x_est, y_est = test_func(img1, img2)
# print("x: {0:.3f}, x: {0:.3f}".format(x_true, y_true))
# print("x: {0:.3f}, y: {0:.3f}".format(x_est, y_est))
value = math.sqrt((x_true - x_est)**2 + (y_true - y_est)**2)
error_all[i] = value
ave = np.average(error_all)
std = np.std(error_all)
print("\terror: {0:.3f} +- {1:.3f}".format(ave, std))
#------------------------------
# main
#------------------------------
poc.py 文件源码
python
阅读 35
收藏 0
点赞 0
评论 0
评论列表
文章目录