Writing values got from template matching to new image
Hi, Could you please help me with the task? I have to write values of correlation coefficient between two images to the new one. I am trying to compare two same size images (116x206px) by cropping 10x10 patches of images and trying to match them and get correlation coefficient. I would like to get a result from each comparison and write it to a new image as a pixel with value of the tempalte matching. I don't know Python at all so forgive me bugs. Thanks in advance!
import cv2
import numpy as np
img = cv2.imread('image.jpg',0)
template = cv2.imread('template.jpg',0)
w, h = template.shape[::-1]
img_res = np.zeros((16,20,1),np.uint8)
i = 0
j = 0
k = 0
l = 0
while (i < w):
while (j < h):
img_crop = img[i:i+10, j:j+10]
template_crop = template[i:i+10, j:j+10]
res = cv2.matchTemplate(img_crop, template_crop, cv2.TM_CCOEFF)
img_res[k, l] = res
i = i+10
j = j+10
k = k+1
l = l+1
cv2.imshow(img_res)