0

我试图从 match_template 中理解某人的代码,但我无法理解下面的过程。假设有一张照片他要切几部分。图片保存在:

ImagenTotal = np.asarray(Image.open('./redmangos.jpg'))

然后他在该图片上选择了 2 个位置,坐标为:

puntosinteres = [[189.7038558467742, 111.99546370967738],[211.1748235887097, 187.9696572580645]]

由于 match_template 需要两个参数 - 一个是原始图片,另一个是他将用来比较的内容。那么下面的流程是这样的:

xinteres = int(puntosinteres[0][0]) 
yinteres = int(puntosinteres[0][1])
radio = 10
imagenband = ImagenTotal[:,:,0]
templateband = ImagenTotal[yinteres - radio : yinteres + radio, xinteres - radio : xinteres + radio, 0]
result= match_template(imagenband, templateband)
result = np.where(result>0.8)

我不知道他想在 imagenband 和 templateband 上做什么。有人可以指点我一个方向吗?

谢谢!

4

1 回答 1

1

imagenband从 , 中获取第 0 个通道ImagenTotal以获取单个灰度图像。从(西班牙语中的半径)到行轴和列轴上templateband抓取一个小的 20x20 矩形。yinteres - radioyinteres + radioxinteres - radioxinteres + radio

要了解更多关于索引如何用于 numpy 数组的信息,您可以在此处阅读有关索引的官方文档:

https://numpy.org/doc/stable/user/basics.indexing.html#basics-indexing

那里有更多高级索引主题的链接。

于 2020-06-27T14:31:37.797 回答