Template matching behavior - Color
I am evaluating template matching algorithm to differentiate similar and dissimilar objects. What I found is confusing, I had an impression of template matching is a method which compares raw pixel intensity values. Hence when the pixel value varies I expected Template Matching to give a less match percentage.
I have a template and search image having same shape and size differing only in color(Images attached). When I did template matching surprisingly I am getting match percentage greater than 90%.
img = cv2.imread('./images/searchtest.png', cv2.IMREAD_COLOR)
template = cv2.imread('./images/template.png', cv2.IMREAD_COLOR)
res = cv2.matchTemplate(img, template, cv2.TM_CCORR_NORMED)
min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(res)
print(max_val)
Can someone give me an insight why it is happening so? I have even tried this in HSV color space, Full BGR image, Full HSV image, Individual channels of B,G,R and Individual channels of H,S,V. In all the cases I am getting a good percentage.
Any help could be really appreciated.
EDIT:
try https://github.com/LaurentBerger/Colo...
@LBerger: Thanks for pointing me a resource, Do you have any write up or blog I couldnt able to interpret the results I am getting.
I haven't got any blog. But Have you got a problem with this code?
I am not familiar with the frequency domain operations. Not getting intuition like the OpenCV's template matching
it's here https://github.com/LaurentBerger/Colo... give color images as parameters (image and template) and result is imgcorr. imgcorr is a real images (CV_64F). you can call minMaxLoc to find maximun location
@LBerger: Added the result of your code. what is the level parameter?
Try new version it's much better