Computing Correlation Coefficients in Python

Published on Dec. 5, 2007, 2:59 a.m.

image numpy pil python

A useful technique for matching objects in images is to compute the images' Correlation Coefficients. Essentially, you take any image and compute the correlation between it and another, smaller image containing ONLY the object that you want to identify. The resulting correlation image should contain bright spots where there is a high correlation (or match) between the two images.

Here's a simple python script to compute the correlation between two images:

It requires PIL and numpy, and it's fairly inefficient, but it's a simple, straightforward implementation.

comments powered by Disqus