I am experimenting with some computer vision techniques, specifically feature detection. I am trying to identify features by conducting auto-correlation between an image and a feature-kernel.
However, the resulting correlation-matrix doesn't make sense to me... Can anyone help me understand how to interpret or visualize this matrix, so that it's apparent where the feature is located?
Feature Kernel:
Original Image:
Code:
import cv2
import pprint
import numpy
import scipy.ndimage
from matplotlib import pyplot as plt
import skimage.feature
# load the image
img = cv2.imread('./lenna.jpg')[:,:,0]
f_kernel = cv2.imread('./lenna_feature.jpg')[:,:,0]
def matched_filter(img, f_kernel, detect_thres):
result = scipy.ndimage.correlate(img, f_kernel)
print("Feature Match Template")
plt.imshow(skimage.feature.match_template(img, f_kernel))
plt.show()
return result
plt.imshow(matched_filter(img,f_kernel,1))
print("Correlation Matrix")
plt.show()
Result:
So, in the first result-image, there's an obvious maximum-point at (150,200). I am interpreting this as the most likely location of the feature.
However, in the second result-image, correlation matrix result, there is no obvious pattern. I was expecting that there would be some, obvious high-correlation point.
Help?