Python 如何向特定点放大图像+;缩放后跟踪特定点

Python 如何向特定点放大图像+;缩放后跟踪特定点,python,image,matlab,zooming,Python,Image,Matlab,Zooming,我想将图像放大到图像中特定的定义点 另外,图像中有一个边界框,我知道它的四个角的坐标。我希望在放大图像时跟踪这些点,在放大图像后,如果边界框仍在放大图像中,我将获得放大图像中边界框4个角的坐标。我建议使用matplotlib作为示例 import matplotlib.pyplot as plt import matplotlib.patches as patches import numpy as np f = plt.figure() ax = f.add_subplot(111) #

我想将图像放大到图像中特定的定义点


另外,图像中有一个边界框,我知道它的四个角的坐标。我希望在放大图像时跟踪这些点,在放大图像后,如果边界框仍在放大图像中,我将获得放大图像中边界框4个角的坐标。

我建议使用matplotlib作为示例

import matplotlib.pyplot as plt
import matplotlib.patches as patches

import numpy as np

f = plt.figure()
ax = f.add_subplot(111)

#create 2d array
t = np.linspace(0, 1, 101)
x, y = np.meshgrid(t, t)
img = np.sin(x-0.5)*np.sin(y-0.5)

ax.imshow(img, origin='lower', extent=[0, 1, 0, 1])
#create a rectangle at positions 0.1, 0.1 with width/height 0.5
#so this would be your bounding box from points (0.1, 0.1), (0.6,0.6) etc
rectangle = patches.Rectangle((0.1, 0.1), 0.5, 0.5, fill=False)
ax.add_patch(rectangle)

plt.show()

print ax.get_xlim()
print ax.get_ylim()
这将在绘图显示后创建以下输出

因此,在matplotlib中打开此绘图后,可以使用鼠标右键放大绘图。如果关闭绘图,程序流程将继续执行
print ax.get\u xlim()
等。。 这将为您提供绘图的新限制,您应该能够从中计算新的点位置


我不知道您对python/matplotlib有多熟悉,但这应该是非常直接的,否则如果您需要更多解释,请告诉我

我不明白问题到底出在哪里?是什么阻止你做你想做的事?鼠标右键不起作用。而且图像没有缩放。看一看