import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
def _get_gauss_response(self, img, gt):
# get the shape of the image..
height, width = img.shape#取图片的长宽
# 获取网格...
xx, yy = np.meshgrid(np.arange(width), np.arange(height))#画网格
# 得到物体的中心...
center_x = gt[0] + 0.5 * gt[2]
center_y = gt[1] + 0.5 * gt[3]
dist = (np.square(xx - center_x) + np.square(yy - center_y)) / (2 * self.args.sigma)
# 获取响应映射...
response = np.exp(-dist)
response = linear_mapping(response)
fig = plt.figure()
ax = Axes3D(fig)
ax.plot_surface(xx, yy, response, cmap='jet')
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
plt.show()
从MOSSE复现代码中截取的部分