我有一个示例代码如下:
def DrawMTF(img, edges, perm, mtfs, crop_ratio, color_map_range):
"""Draws the result of the image sharpness test on the test image."""
# Map MTF values to hue values.
hues = ((mtfs - color_map_range[0]) /
(color_map_range[1] - color_map_range[0])) / 3.0
np.clip(hues, 0.0, 1.0/3, out=hues)
# Draw the edges.
for idx, edge_id in enumerate(perm):
edge = edges[edge_id]
start = (1 - crop_ratio) * edge[0:2] + crop_ratio * edge[2:4]
end = crop_ratio * edge[0:2] + (1 - crop_ratio) * edge[2:4]
cv2.line(img, _FtoI(tuple(_Up(start))), _FtoI(tuple(_Up(end))),
_HSVToBGR(hues[idx], 1.0, 1.0), thickness=2,
shift=_UPSAMPLING_BITS, lineType=cv2.CV_AA)
输出图像如下
我的问题是&#34;我怎么能在边缘附近写出mtf值?&#34; 我使用了API&#34; cv2.putText&#34;,但我不知道该位置,也无法将mtf值的类型转换为&#34;%。3f&#34;。< / p>
我该怎么办?