【问题标题】:How to zoom into an image towards a specific point + keeping track of specific points after zooming [closed]如何将图像放大到特定点+缩放后跟踪特定点[关闭]
【发布时间】:2016-02-18 22:06:06
【问题描述】:

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

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

【问题讨论】:

  • 我不明白问题到底出在哪里?是什么让你无法做你想做的事?

标签: python image matlab zooming


【解决方案1】:

我建议将 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_xlim() 等。 这将为您提供绘图的新限制,您应该能够从中计算新的点位置

我不知道你对 python / matplotlib 有多熟悉,但这应该很简单,否则如果你需要更多解释,请告诉我

【讨论】:

猜你喜欢
  • 2021-06-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-01-05
相关资源
最近更新 更多