Reputation: 395
Hi i would like to bring to your notice there is some issue in the openCV matchTemplate() methods. According to book bhattacharya coefficient is totally different from Normalized cross correalation , but when i tried this chunk of code , i got the same distance everywhere for each image.Can anyone bring this notice to opencv developers and try to tell why this happened. I was trying to find the distance measure using these two methods
path1 = 'D:/cat1.png'
path2 = 'D:/cat2.png'
im1=cv2.imread(path1, cv2.CV_LOAD_IMAGE_GRAYSCALE)
im2=cv2.imread(path2, cv2.CV_LOAD_IMAGE_GRAYSCALE)
result = cv2.matchTemplate(im1,im2,cv.CV_COMP_BHATTACHARYYA) #Bhattacharya Coefficient
result2=cv2.matchTemplate(im1,im2,cv2.TM_CCORR_NORMED) #Normalized Cross Correlation
print"BCC :",result
print '\n'
print"NCC :",result2
Upvotes: 1
Views: 1802
Reputation: 39796
no wonder.
apart from CV_COMP_BHATTACHARYYA not being a valid compare flag for matchTemplate ,
both CV_COMP_BHATTACHARYYA and TM_CCORR_NORMED resolve to the same enum value 3 under the hood.
so basically you're doing the very same thing twice.
Upvotes: 1