用于查看图像中的模式的Python库

时间:2015-02-21 17:59:23

标签: python image

我正在寻找一个可以搜索图像的python库,并找到像https://pyautogui.readthedocs.org/en/latest/screenshot.html#the-locate-functions中那样的小图像文件的坐标。例如,如果我有http://i.stack.imgur.com/hWfBm.png 我想找到野草的所有景点,哪些图书馆可以帮助我做到这一点?

1 个答案:

答案 0 :(得分:0)

安装OpenCV库并链接到系统路径中的Python绑定。如果您不知道如何操作,请尝试Youtube以获取与您的操作系统相关的说明。从那里,保存包含一块草的图像。

import cv2  
import numpy as np 

world = cv2.imread("world.png") # entire world image  
grass = cv2.imread("grass.png") # grass image

result = cv2.matchTemplate(world, grass, cv2.TM_CCOEFF_NORMED)  
print np.unravel_index(result.argmax(), result.shape)
相关问题