0

There are many instances of subimage present inside the main image. I want to extract all the coordinates of the sub images from the main image. I could able to extract for only one. Kindly assist in the same

import cv2  
import numpy as np  
image = cv2.imread("Large.png")  
template = cv2.imread("small.png")  
result = cv2.matchTemplate(image,template,cv2.TM_CCOEFF_NORMED)  
print np.unravel_index(result.argmax(),result.shape)

_, w, h = template.shape[::-1]
threshold = 0.5
loc = np.where( res >= threshold)
coordinates = zip(loc[0], loc[1])
print coordinates
  • Use `np.where`? Seems relevant : https://stackoverflow.com/questions/32531377. – Divakar Apr 27 '20 at 20:11
  • Tried but no luck getting the coordinates. It returns me the array but i want the coordinates. Please help me out how to implement np.where in the above code to get all the coordinates – NAVEEN DANIEL Apr 27 '20 at 20:20
  • Just use the linked Q&A solutions? – Divakar Apr 27 '20 at 20:21
  • @Divakar I tried with np.where and it gave me the coordinates of all the points of the image. I want only a specific point or the coordinate of the image. Kindly please assist in the same – NAVEEN DANIEL Apr 29 '20 at 15:02
  • @Mark Setchelll I tried with np.where and it gave me the coordinates of all the points of the image. I want only a specific point or the coordinate of the image. Kindly please assist in the same – NAVEEN DANIEL Apr 29 '20 at 15:03

0 Answers0