I'm using Template Matching to detect for smaller images in a large image. After detecting it , i would grab the center point(x y) of main picture of the detected image.
Could anyone advice how I could grab the shade/color of that particular center point?
I understand the Template Matching ignores color , based this example, is there anyway to grab the color intensity of the particular pixel? of that center point
# Python program to illustrate
# template matching
import cv2
import numpy as np
import time
import sys
# Read the main image
img_rgb = cv2.imread('test.png')
# Convert it to grayscale
img_gray = cv2.cvtColor(img_rgb, cv2.COLOR_BGR2GRAY)
# Read the template
template = cv2.imread('template.png',0)
# Store width and heigth of template in w and h
w, h = template.shape[::-1]
# Perform match operations.
res = cv2.matchTemplate(img_gray,template,cv2.TM_CCOEFF_NORMED)
# Specify a threshold
threshold = 0.90
# Store the coordinates of matched area in a numpy array
loc = np.where( res >= threshold)
xyMiddle = ""
for pt in zip(*loc[::-1]):
xyMiddle = str(pt[0] + w/2) +"," +str(pt[1] + h/5)
if(xyMiddle != ""):
print(xyMiddle)