
NCC is one of those quantities with application in a variety of research fields as diverse as physics, signal processing, engineering, medical imaging, and statistical finance. The simplest form of the normalized cross-correlation (NCC) is the cosine of the angle θ between two vectors a and b: This dependency is eliminated if one uses the normalized form of the covariance, referred to as the normalized cross-correlation (otherwise known as the correlation coefficient). A serious setback of the covariance is its dependence on the amplitude of either of the series that are compared.

If you use this method on good-resolution images, you should increase the patch size for more accurate results (d=2 or 3).Covariance, by definition, provides a measure of the strength of the correlation between two sets of numbers (or time series). If a pixel has a large correlation index between two images, it means that the region of the face where this pixel is located does not change much between the images. In the article, I think the idea is to measure whether face expressions look similar or not. For faster execution, you could for example port the script to Cython. The code above is a naive and slow implementation of the correlation, as the two for loops are very slow.

Im2_register = ndimage.shift(im2, translation)Ĭorrelation = correlation_coefficient(im1[i - d: i + d + 1, Translation = feature.register_translation(im1, im2, upsample_factor=10) Im = io.imread('faces.jpg', as_grey=True) from skimage import io, featureĭef correlation_coefficient(patch1, patch2):

The output looks different from the one of the article, but it was to be expected since the resolution is very different. Here is an example where I downloaded the figure attached here and tried to compute the correlation in such a way.

I guess you can compute for each pixel the correlation coefficient between patches centered on this pixel in the two images of interest.
